Help: transform unix time format to standard


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help: transform unix time format to standard
# 1  
Old 11-17-2010
Help: transform unix time format to standard

Hello All,

Do you have any idea, how can I transform the unix time format to standard:

time_last_login=1268057983 Smilie

I would like to use the transformation in a AIX shell script Smilie
# 2  
Old 11-17-2010
Code:
$ perl -e "print scalar(localtime(1268057983))"
Mon Mar  8 15:19:43 2010

# 3  
Old 11-18-2010
Its works, thats cool, thanks Smilie

Its possible to do that without perl? Just for theoretically. Smilie
# 4  
Old 11-18-2010
By GNU date:

Code:
date -d @1268057983

by awk

Code:
awk 'BEGIN{print strftime("%Y-%m-%d",1268057983 )}'
2010-03-09

@cabrao
Seems we are in different time zone.

Last edited by rdcwayx; 11-18-2010 at 07:26 AM..
# 5  
Old 11-18-2010
The last two solutions are not working on AIX Smilie

date -d on AIX not a recognized flag

==========================================

and the
awk 'BEGIN{print strftime("%Y-%m-%d",1268057983 )}'
awk: 0602-553 Function strftime is not defined.
The source line number is 1.
# 6  
Old 11-18-2010
Another way would be to use the printf builtin of the kornshell 93.

Code:
$ printf "%(%a %Y-%m-%d %T)T\n" '#'1268057983
Mon 2010-03-08 15:19:43

# 7  
Old 11-22-2010
Would be good in simple ksh Smilie

Perl is good, but i think not all servers have perl package installed. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

How to Understand the UNIX Time Format?

How to understand the unix time format as here i have pasted this is a unix time 1402565420 and its 3:00 PM here but its give this Output as long number How can i make it to understand format as i have 3:00 PM Normal time format <----3:00PM = 1402565420----> Unix Time Will Any one Explain to... (4 Replies)
Discussion started by: babinlonston
4 Replies

2. Shell Programming and Scripting

Change the date and time format in UNIX script.

Hi, I am extracting a date string from the source file like this : 06/05/2014 16:04:00 I want to change it to 05-JUN-14 04.05.00.000000000 PM I basically store the date in a variable. I got solutions to change date in dd-mmm-yyyy format using tr but I guess it works only with the "date"... (8 Replies)
Discussion started by: Varshha
8 Replies

3. Shell Programming and Scripting

Calculating the epoch time from standard time using awk and calculating the duration

Hi All, I have the following time stamp data in 2 columns Date TimeStamp(also with milliseconds) 05/23/2012 08:30:11.250 05/23/2012 08:30:15.500 05/23/2012 08:31.15.500 . . etc From this data I need the following output. 0.00( row1-row1 in seconds) 04.25( row2-row1 in... (5 Replies)
Discussion started by: ks_reddy
5 Replies

4. Shell Programming and Scripting

Changing the format of the unix time command

Hello. I use time in order to calculate the execution time of a program. The output format is: real 0m0.059s user 0m0.028s sys 0m0.004s Is there a simple and elegant way to add user and sys together, and convert to milliseconds? Thanks a lot! (4 Replies)
Discussion started by: dynelight
4 Replies

5. Shell Programming and Scripting

Date conversion from Standard/given format to seconds/epoch

I am trying get time difference of two dates in secs. Initially I want to convert a standard date format to epoch for two dates and then subtract the two epoch dates. Example : date -d "2007-09-01 17:30:40" '+%s' But this gives me below error date: illegal option -- d Usage: date OS: AIX... (6 Replies)
Discussion started by: bpaac
6 Replies

6. Shell Programming and Scripting

Convert Unix Time to Standard Time

I have a list of interfaces and time the interface was last active. I can't figure out how to convert the time in the second column, Fa1/14 0 Se0/0/0 0 Fa1/11 0 Fa1/9 0 Fa1/0 0 Se0/0/1 1240401408 Gi1/0 0 Fa0/0 1240401408 Fa1/3 0 Fa1/8 0 Fa1/15 0 Fa1/13 0 Fa1/10 0 Fa1/1 0 Fa1/12... (7 Replies)
Discussion started by: mrlayance
7 Replies

7. Shell Programming and Scripting

Convert Epoch Time to Standard Date and Time & Vice Versa

Hi guys, I know that this topic has been discuss numerous times, and I have search the net and this forum for it. However, non able to address the problem I faced so far. I am on Solaris Platform and unable to install additional packages like the GNU date and gawk to make use of their... (5 Replies)
Discussion started by: DrivesMeCrazy
5 Replies

8. Shell Programming and Scripting

Convert Epoch time format to normal date time format in the same file

I have a file named "suspected" with series of line like these : {'protocol': 17, 'service': 'BitTorrent KRPC', 'server': '219.78.120.166', 'client_port': 52044, 'client': '10.64.68.44', 'server_port': 8291, 'time': 1226506312L, 'serverhostname': ''} {'protocol': 17, 'service': 'BitTorrent... (3 Replies)
Discussion started by: rk4k
3 Replies

9. Windows & DOS: Issues & Discussions

conversion of unix time format

help me to convert unix time format into windows time format using java i have linux time ex. 1075329297.572 (2 Replies)
Discussion started by: sari
2 Replies

10. Shell Programming and Scripting

Convert milliseconds to standard time

hello, I have the uptime of the server showing as upTime=2427742050 How do I convert it to standard time. Thanks Chiru (1 Reply)
Discussion started by: chiru_h
1 Replies
Login or Register to Ask a Question