I have a Perl script I'm writing where I ask the user to enter a "start time" for something. The "$start_time" will be in the format of:
So what I do is pull out the number from the option supplied, convert it to seconds, then add those seconds to the current
"UNIX Time" which is calculated using -->my "$current_time = timelocal($sec,$min,$hour,$mday,$mon,$year);".
So if the following is the Current Time and the option supplied by the user:
Now that I have the Future time in seconds (i.e. UNIX/Epoch Time) I should be able to take those seconds then convert it
to a human-readable format.
But after I convert the future UNIX-Time to a regular date format it is actually giving me the following:
As you can see in the output from the "date" command it is showing the "future start time" as what looks like 29 hours or so into the future. Instead of being 24-Hours, which is how
many seconds I added to the UNIX-Time...
Does anyone know if I'm not doing this correctly? I figure my output, if the start_time = 24 hours, should actually be: 05-18-2013 12:42:07 PM
Maybe I need to specify a time zone, or something like that???
Any thoughts or suggestions would be greatly appreciated!
Thanks in Advance,
Matt
---------- Post updated at 01:58 PM ---------- Previous update was at 01:14 PM ----------
Humm.. I think this method will work for converting a future UNIX-Timestamp to a Readable Date format:
Not positive yet but it looks like that method works.
_________________
Getting the incorrect year though... I must be doing something wrong...
Use POSIX module and the strftime routine as shown below. To ensure that your perl code is portable, ensure that you use date formats that are ANSI C standard. %r is not one.
This User Gave Thanks to balajesuri For This Post:
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)
I have unix epoch time 1441678454803, Can you please help me to print this time in below format ?
DAY,HOUR,MIN,SEC
Appreciate your help!!!
Thanks,
Prince (7 Replies)
I have a requirement to find long running instances for notifying the stake holders based on the triggered time in AIX.
I am not sure how to convert the triggered time to epoch seconds.
For example :
Current triggered time of instance is 13:06:19 -> how to convert this into epoch in the... (5 Replies)
I needed some help in adding a duration (in seconds) to a start time (in hhmmss format) and a start date (in mmddyy format) in order to get an end date and end time. The concept of a leap year is also to be considered while incrementing the day. The code/ function that I have formed so far is as... (3 Replies)
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)
Hi All,
In our code we are using below code to calculate the UNIX Epoch Time from the time stamp present in the file.
Can any one explain how the DC operates in below command and how we calculate the UNIX EPOCH time from this.
Date incide the file is 20:26:51
Output we get is 1289943554... (3 Replies)
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)