![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Newbie
Join Date: Mar 2006
Location: Olympia WA USA
Posts: 11
Rep Power: 0
![]() |
Date Routine
This may be old news to some but at the same time may be of value to someone else.
I was recently faced with creating a date stamp for the previous day's date. Using some hints found online, I concocted the following routine which works nicely: ### function to build dstamp (date stamp for previous day's date) my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time - 86400); $mon = $mon + 1; $year = $year + 1900; $dstamp = sprintf "%04d%02d%02d", $year, $mon, $mday; ### end of dstamp function The nice thing is that the value 86400 in the call to 'localtime' is equivalent to one (1) day ... so, by adjusting this value, you can create the same sort of date stamp (format is YYYYMMDD) for any offset. Enjoy! Tom
__________________
My mind is like a steel whatchamacallit ... |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| converting string to float | beginnerCCC | C | 22 | Oct 2nd, 2006 11:59 PM |
| Creation date comparison for subdirectories | randum77 | Visual Basic .NET | 6 | Jul 22nd, 2006 8:40 AM |
| Php Postgresql Class | Pizentios | Show Off Your Open Source Projects | 15 | Jun 28th, 2005 9:55 AM |
| Date Method | Abyss | Java | 2 | Apr 10th, 2005 8:47 AM |
| Enquiry About Visual Basic Project | kbkhoo5053 | Visual Basic | 13 | Feb 15th, 2005 2:20 AM |