09-18-2012
@Rashu123: From your first post, what does $DATE, $TIME contain? Please provide sample input and expected output.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Solaris 10 doesn't seem to like me a lot. I am trying to run a simple script to accept date and return epoch of that date:
#!/usr/bin/perl -w
use strict;
use Time::ParseDate;
my($date1)="Mon Mar 27 05:54:08 CDT 2009";
chomp $date1;
#Convert to seconds since start of epoch
my $time1 =... (3 Replies)
Discussion started by: pavanlimo
3 Replies
2. Shell Programming and Scripting
Hello
I have a the creation date of a file stored in a variable in the following format:
Wed May 06 10:14:58 2009Is there a way I can echo the variable and display it in epoch time?
I've done a lot of searching on this topic, but haven't managed to get a solution. I'm on Solaris 10.
... (2 Replies)
Discussion started by: Glyn_Mo
2 Replies
3. Shell Programming and Scripting
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
4. Shell Programming and Scripting
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
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
6. Shell Programming and Scripting
Need assistance in converting an epoch time to Julian date
To get epoch
perl -e 'use Time::Local; print timelocal(1,5,2,12,10,2008), "\n"' (3 Replies)
Discussion started by: ajayram_arya
3 Replies
7. Shell Programming and Scripting
I am not able to pass date stored in a variable as an argument to date command. I get current date value for from_date and to_date
#!/usr/bin/ksh
set -x
for s in server ; do
ssh -T $s <<-EOF
from_date="12-Jan-2015 12:02:09"
to_date="24-Jan-2015 13:02:09"
echo \$from_date
echo... (7 Replies)
Discussion started by: raj48
7 Replies
8. Shell Programming and Scripting
Hi All,
I have scenario where i have to compare two dates.
I thought of converting them to epoch seconds and do a numeric comparison.
This works fine on Linux systems.
$ date -d '2015/12/31' +%s
1451538000
$ date +%s
1449159121
But we don't have -d option in HPUX.
What would be... (5 Replies)
Discussion started by: veeresh_15
5 Replies
9. Shell Programming and Scripting
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
10. Shell Programming and Scripting
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 FREEBSD
time2posix
TIME2POSIX(3) BSD Library Functions Manual TIME2POSIX(3)
NAME
time2posix, posix2time -- convert seconds since the Epoch
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <time.h>
time_t
time2posix(time_t t);
time_t
posix2time(time_t t);
DESCRIPTION
IEEE Std 1003.1-1988 (``POSIX.1'') legislates that a time_t value of 536457599 shall correspond to "Wed Dec 31 23:59:59 GMT 1986." This
effectively implies that POSIX time_t's cannot include leap seconds and, therefore, that the system time must be adjusted as each leap
occurs.
If the time package is configured with leap-second support enabled, however, no such adjustment is needed and time_t values continue to
increase over leap events (as a true `seconds since...' value). This means that these values will differ from those required by POSIX by the
net number of leap seconds inserted since the Epoch.
Typically this is not a problem as the type time_t is intended to be (mostly) opaque--time_t values should only be obtained-from and passed-
to functions such as time(3), localtime(3), mktime(3) and difftime(3). However, IEEE Std 1003.1-1988 (``POSIX.1'') gives an arithmetic
expression for directly computing a time_t value from a given date/time, and the same relationship is assumed by some (usually older) appli-
cations. Any programs creating/dissecting time_t's using such a relationship will typically not handle intervals over leap seconds cor-
rectly.
The time2posix() and posix2time() functions are provided to address this time_t mismatch by converting between local time_t values and their
POSIX equivalents. This is done by accounting for the number of time-base changes that would have taken place on a POSIX system as leap sec-
onds were inserted or deleted. These converted values can then be used in lieu of correcting the older applications, or when communicating
with POSIX-compliant systems.
The time2posix() function is single-valued. That is, every local time_t corresponds to a single POSIX time_t. The posix2time() function is
less well-behaved: for a positive leap second hit the result is not unique, and for a negative leap second hit the corresponding POSIX time_t
does not exist so an adjacent value is returned. Both of these are good indicators of the inferiority of the POSIX representation.
The following table summarizes the relationship between time_t and its conversion to, and back from, the POSIX representation over the leap
second inserted at the end of June, 1993.
DATE TIME T X=time2posix(T) posix2time(X)
93/06/30 23:59:59 A+0 B+0 A+0
93/06/30 23:59:60 A+1 B+1 A+1 or A+2
93/07/01 00:00:00 A+2 B+1 A+1 or A+2
93/07/01 00:00:01 A+3 B+2 A+3
A leap second deletion would look like...
DATE TIME T X=time2posix(T) posix2time(X)
??/06/30 23:59:58 A+0 B+0 A+0
??/07/01 00:00:00 A+1 B+2 A+1
??/07/01 00:00:01 A+2 B+3 A+2
[Note: posix2time(B+1) => A+0 or A+1]
If leap-second support is not enabled, local time_t's and POSIX time_t's are equivalent, and both time2posix() and posix2time() degenerate to
the identity function.
SEE ALSO
difftime(3), localtime(3), mktime(3), time(3)
BSD
September 11, 2005 BSD