in reply to Re: Date Time problem.
in thread Date Time problem.
The general way to do "time math" is to convert to epoch seconds, do math in seconds and then convert back to a string.
Except it doesn't work. Not all days have 24*60*60 seconds.
the OP's idea of adding zero is a GREAT idea.
And POSIX's strftime is the way to do it if you're already dealing with localtime or gmtime (It handles the y+1900 and the m+1 for you.)
use POSIX qw( strftime ); print( strftime('%Y%m%d', localtime), "\n");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Date Time problem.
by Marshall (Canon) on Sep 05, 2009 at 04:00 UTC | |
by ikegami (Patriarch) on Sep 05, 2009 at 04:53 UTC | |
by Marshall (Canon) on Sep 05, 2009 at 06:35 UTC | |
by ikegami (Patriarch) on Sep 05, 2009 at 07:17 UTC | |
by Marshall (Canon) on Sep 05, 2009 at 08:21 UTC | |
|