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 functions.
Hence, I intend to go for Perl and include a one-liner command in the shell script for the conversion.
As you can see below, I have no problem converting Epoch to Standard Date/Time.
But for converting Standard Date/Time to Epoch, I am not getting the correct Epoch value.
Am I missing anything here?
Convert Epoch to Standard Date/Time Convert Standard Date/Time to Epoch
Is there an easy method to do an on the fly conversion of a standard epoch time (seconds from 1970) to more readable date format?
Does Unix have anything built in to do this? (4 Replies)
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)
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)
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)
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)
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)
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)
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)
Hello Team,
I am stuck in getting the required output in the following case. Please help.
My input file is
aa|08/01/2016
bb|08/15/2016
I wish to convert the file into
aa|epoch time
bb|epoch time
I am using following code: (3 Replies)
Discussion started by: angshuman
3 Replies
LEARN ABOUT DEBIAN
time::y2038
Time::y2038(3pm) User Contributed Perl Documentation Time::y2038(3pm)NAME
Time::y2038 - Versions of Perl's time functions which work beyond 2038
SYNOPSIS
use Time::y2038;
print scalar gmtime 2**52; # Sat Dec 6 03:48:16 142715360
DESCRIPTION
On many computers, Perl's time functions will not work past the year 2038. This is a design fault in the underlying C libraries Perl uses.
Time::y2038 provides replacements for those functions which will work accurately +/1 142 million years.
This only imports the functions into your namespace. To replace it everywhere, see Time::y2038::Everywhere.
Replaces the following functions:
gmtime()
See "gmtime" in perlfunc for details.
localtime()
See "localtime" in perlfunc for details.
timegm()
my $time = timegm($sec, $min, $hour, $month_day, $month, $year);
The inverse of "gmtime()", takes a date and returns the coorsponding $time (number of seconds since Midnight, January 1st, 1970 GMT). All
values are the same as "gmtime()" so $month is 0..11 (January is 0) and the $year is years since 1900 (2008 is 108).
# June 4, 1906 03:02:01 GMT
my $time = timegm(1, 2, 3, 4, 5, 6);
timegm() can take two additional arguments which are always ignored. This lets you feed the results from gmtime() back into timegm()
without having to strip the arguments off.
The following is always true:
timegm(gmtime($time)) == $time;
timelocal()
my $time = timelocal($sec, $min, $hour, $mday, $month, $year);
my $time = timelocal($sec, $min, $hour, $mday, $month, $year, $wday, $yday, $isdst);
Like "timegm()", but interprets the date in the current time zone.
"timelocal()" will normally figure out if daylight savings time is in effect, but if $isdst is given this will override that check. This
is mostly useful to resolve ambiguous times around "fall back" when the hour between 1am and 2am occurs twice.
# Sun Nov 4 00:59:59 2007
print timelocal(59, 59, 0, 4, 10, 107); # 1194163199
# Sun Nov 4 01:00:00 2007 DST, one second later
print timelocal(0, 0, 1, 4, 10, 107, undef, undef, 1); # 1194163200
# Sun Nov 4 01:00:00 2007 no DST, one hour later
print timelocal(0, 0, 1, 4, 10, 107, undef, undef, 0); # 1194166800
$wday and $yday are ignored. They are only there for compatibility with the return value of "localtime()".
LIMITATIONS
The safe range of times is +/ 2**52 (about 142 million years).
Although the underlying time library can handle times from -2**63 to 2**63-1 (about +/- 292 billion years) Perl uses floating point numbers
internally and so accuracy degrates after 2**52.
BUGS & FEEDBACK
See http://rt.cpan.org/Dist/Display.html?Queue=Time-y2038 to report and view bugs.
If you like the module, please drop the author an email.
The latest version of this module can be found at http://y2038.googlecode.com/ and the repository is at
http://y2038.googlecode.com/svn/trunk/ in perl/Time-y2038. You have to check out the whole repository because there are symlinks.
AUTHOR
Michael G Schwern <schwern@pobox.com>
LICENSE & COPYRIGHT
Copyright 2008-2010 Michael G Schwern
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html
SEE ALSO
Time::y2038::Everywhere overrides localtime() and gmtime() across the whole program.
The y2038 project at http://y2038.googlecode.com/
<http://xkcd.com/376/>
perl v5.14.2 2011-11-15 Time::y2038(3pm)