[prog] Perl dates

k.clair kclair at karl.serve.com
Sun Feb 16 10:39:31 EST 2003


 You can get info about the date and time using the time() and
 localtime() functions.
 
 time() returns a time that localtime() can understand :)
 from perldoc.com: "Returns the number of non-leap seconds since whatever
 time the system considers to be the epoch (that's 00:00:00, January 1,
 1904 for Mac OS, and 00:00:00 UTC, January 1, 1970 for most other
 systems). Suitable for feeding to gmtime and localtime."
 
 
 localtime() returns an array based on the time passed to it:
 
 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
                         localtime(time);
 
 For anything more complicated you would probably want to look into the
 Date modules available from cpan.  There is Date::Simple which is good,
 which has a format() function.
 
 hope that helps,
 kristina
 
- On Mon, Feb 17, 2003 at 12:30:57AM +1100, Sue Stones wrote:
- - I have been trying to figgure out how to get a date in the form "mmyyyy" but
- - haven't succeeded. I can get a beutifully formatted string using the unix
- - `date` command, but that is not what I want this format to name log files.
- - 
- - The only perl book that i have at the moment is "perl in 24 hrs" ~ or
- - something to that effect.  I may have to get a better book, when I can
- - afford it.
- - 
- - 
- - thanks
- - sue
- - 
- - 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 240 bytes
Desc: not available
Url : http://linuxchix.org/pipermail/programming/attachments/20030216/b63440df/attachment.pgp


More information about the Programming mailing list