how to convert epoch time to readible format?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to convert epoch time to readible format?
# 1  
Old 12-19-2005
Question how to convert epoch time to readible format?

Hi,
I would like to convert epoch time from the logs to readible fromat.
How do I do it within shell?

Thanks!
# 2  
Old 12-19-2005
what OS are you on?
# 3  
Old 12-19-2005
what OS are you on?

what's the command to do it?
# 4  
Old 12-19-2005
OS config

ok.
Here it is:
System Configuration: Sun Microsystems sun4u
Memory size: 512 Megabytes
# 5  
Old 12-19-2005
Aim this module at your perl ie., #!/path/to/your/perl
Code:
#!/usr/bin/perl
# date from time_t seconds since the start of epoch  then.pl
$then = localtime($ARGV[0]); 
print("$then\n");

usage:
Code:
logdate=`then.pl <time since start of epoch>`
echo "$logdate"

# 6  
Old 12-19-2005
Code:
#!/bin/ksh

# here's my current EPOCH time
currentEpoch=$(/usr/bin/truss /usr/bin/date 2>&1 | /usr/bin/awk '/^time/ {print $NF}')

# here we convert EPOCH back to human readable format
back2Human=$(echo "0t${currentEpoch}=Y" | /usr/bin/adb)

echo "date->[$(date)] currentEpoch->[${currentEpoch}] back2Human->[${back2Human}]"

# 7  
Old 12-19-2005
cin2000, "uname -a" will tell you the os.

vger99, I like that procedure to to get the internal time. I'll never use it, mind you. But I like it anyway. Smilie Another way which requires root (or at least non-standard) permission: "echo time/D | adb -k" I used to like these adb tricks but since 64 bit kernels started to arrive they are not as much fun. On a 64 bit kernel, you may need: "echo time+4/D | adb -k"

Between the 32/64 bit confusion and the user permission problems, I have started using perl for this stuff: perl -e 'print time, "\n"'.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert a string to epoch time

Team, I am working on a shell script and i am extracting a date string in "SunOS server" with below format. Mon Jan 21 04:13:48 EST 2021 Can you please assist me the best way to convert the extracted string to epoch time like "date +%s" in Linux. Thanks in advance (1 Reply)
Discussion started by: Girish19
1 Replies

2. 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

3. Shell Programming and Scripting

Convert to epoch time

how can i modify the following command to instead provide the epoch time of the interfaces file? perl -le 'print scalar localtime ((stat "/home/skysmart/interfaces"))' Tue Feb 19 03:44:52 2013 i'm hoping to get the equivalent of this command: stat --format=%Y /home/skysmart/interfaces ... (2 Replies)
Discussion started by: SkySmart
2 Replies

4. Shell Programming and Scripting

Using awk or nawk to convert epoch time to date format

Looking for some help and usually when I do a search this site comes up. Hopefully someone can give me a little direction as to how to use one of these two commands to achieve what I'm trying to do. What am I trying to do? I need to take the time value in epoch format returned from the... (5 Replies)
Discussion started by: minigts
5 Replies

5. Shell Programming and Scripting

Shell script to convert epoch time to real time

Dear experts, I have an epoch time input file such as : - 1302451209564 1302483698948 1302485231072 1302490805383 1302519244700 1302492787481 1302505299145 1302506557022 1302532112140 1302501033105 1302511536485 1302512669550 I need the epoch time above to be converted into real... (4 Replies)
Discussion started by: aismann
4 Replies

6. 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

7. Shell Programming and Scripting

Need to convert an epoch date to MMDDYYHHmm format

System: HP-UX Kornshell Perl is installed, but not POSIX Hello, I am calculating a future date/time. To do this I take the system date in epoch format and add to it. I now need to take the new epoch date and convert it to MMDDYYHHmm format. Any help with this is greatly appreciated. (4 Replies)
Discussion started by: LetsGoPens
4 Replies

8. Shell Programming and Scripting

how to convert date time to epoch time in solaris

Hi, Is there any easy way to convert date time(stored in shell variable ) to epoch time in solaris box? As +%s is working on linux but not on solaris, also -d option is not working. Any suggestion please? (6 Replies)
Discussion started by: anshuman0507
6 Replies

9. 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

10. 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
Login or Register to Ask a Question