convert timezone into human output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting convert timezone into human output
# 1  
Old 07-14-2010
convert timezone into human output

Hi

I have a command which returns a timezone, Ej:

root@bsades2: /usr/local/bin # lsuser -a time_last_login israel
israel time_last_login=1279032223

Question: I want to parse this timezone '1279032223' into a 'martes, 13 de julio de 2010 16:43:43' from the ksh shell. Is itt possible?

thanks in advance
Israel.
# 2  
Old 07-14-2010
Yes. Those are epoch seconds

Code:
#!/bin/ksh

getdate()
{
perl -e '
    use POSIX qw(strftime);
    $mydate = strftime "%c", localtime($ARGV[0]); 
    print $mydate; ' $1
}   

dt=$( getdate 12345678)
echo $dt

The %c format specifier may need to change to match what you want in your own locale. See the date man page for an explanation of all of the date format specifiers.
# 3  
Old 07-14-2010
Nice jim.. :-)

thanks
# 4  
Old 07-14-2010
If you are using ksh93
Code:
printf "%(%A, %d de %B de %Y %H:%M:%S)T" '#'1279032223

outputs (TZ=CEST, LANG=es_ES.utf8)
Code:
martes, 13 de julio de 2010 16:43:43

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert epoch time stamp into human readable format

Can someone help me to write a shell script to convert epoch timestamp into human readable format 1394553600,"test","79799776.0","19073982.728571","77547576.0","18835699.285714" 1394553600,"test1","80156064.0","19191275.014286","62475360.000000","14200554.720000"... (10 Replies)
Discussion started by: Moon1234
10 Replies

2. Shell Programming and Scripting

Multiple records need to convert UNIXtime to human readable datatime and all output in one format

Hello Experts, Below is the record i have: sample data attached I want this record of each row to be in single line and there are multiple rowise unixtime mentioned e.g 11996327 , This needs to be converted to Human readdable data and time from multiple rows Can you help me , it will be... (10 Replies)
Discussion started by: manishK
10 Replies

3. Shell Programming and Scripting

Convert TZ output to a different format

Friends, I am trying to convert my local server timezone EST to UTC and for which I used the TZ command, see below $ date Thu Dec 6 10:14:14 EST 2012 $ $ TZ=UTC date -d '10:14 EST' Thu Dec 6 15:14:00 UTC 2012 Now I would like to have the same output in 'yyyymmdd hh:mm' format. ... (4 Replies)
Discussion started by: vivek_damodaran
4 Replies

4. Shell Programming and Scripting

Convert epoch to human readable date & time format

Hello I have log file from solaris system which has date field converted by Java application using System.currentTimeMillis() function, example is 1280943608380 which equivalent to GMT: Wed, 04 Aug 2010 17:40:08 GMT. Now I need a function in shell script which will convert 1280943608380... (3 Replies)
Discussion started by: Yaminib
3 Replies

5. Shell Programming and Scripting

convert a column to row output?

Getting tired of cut-and-paste...so I thought I would post a question. how do I change this column output to a single row? from this: # vgdisplay -v /dev/vgeva05 | grep dsk | awk '{print $3}' /dev/dsk/c6t0d5 /dev/dsk/c11t0d5 /dev/dsk/c15t0d5 /dev/dsk/c18t0d5 /dev/dsk/c7t0d5... (8 Replies)
Discussion started by: mr_manny
8 Replies

6. Shell Programming and Scripting

Convert timezone

Hi, I have date with my server's timezone. I want to convert it with another timezone either EST or GMT, found Date:Manip module but cant find exact use, can anyone help... (4 Replies)
Discussion started by: darshakraut
4 Replies

7. Shell Programming and Scripting

Convert output to string

Hi Guys, is there any command to convert the output returned by the below command to string format: Code: sed 1!d filename Output is : 108 ---------- Post updated at 11:03 AM ---------- Previous update was at 11:00 AM ---------- Because i am using this output as string parameter ... (4 Replies)
Discussion started by: kam786sim
4 Replies

8. UNIX for Dummies Questions & Answers

how to convert this file output

hi, How do I do this with sed and egrep? is that even possible? I have the following file with this content #OQ#||1|XDzb34_zcSETA|SETA #OQ#||3|XDzc24_zcSETA|SETA #OQ#||4|XDze12_zcSETA|SETA #OQ#||6|XDzf35_zcSETA|SETA #OQ#||7|ADzf38_zc|SETA 1. I want to strip out X and SETA... (5 Replies)
Discussion started by: jbchen
5 Replies

9. Shell Programming and Scripting

script to convert epoch into human-readable

This is what I have to start out with more file 1208217600 1208131200 1193806800 I want to convert the epoch column into a human-readable format. My file has hundreds of these epoch times that I want to loop through and convert. (The epoch time is really the last column of the line) ... (3 Replies)
Discussion started by: snoman1
3 Replies

10. Shell Programming and Scripting

formatting output in human readable numbers

Hi, The following command provides the usage in 1024-byte blocks du -ks * | sort -n | echo "$1" ... 1588820 user10 2463140 user11 2464096 user12 5808484 user13 6387400 user14 ..... I am trying to produce an output of first coulmn by multiplying by 1024 so that the output should... (11 Replies)
Discussion started by: ghazi
11 Replies
Login or Register to Ask a Question