[ale] PERL + SQL Dates
Jason Etheridge
phasefx at magusaptus.com
Tue Apr 27 09:17:55 EDT 2004
> I'm storing my dates in MySQL as "YYYY-MM-DD HH:MM:SS" I need to be
> able in perl to convert that time to epoch and also convert an epoch
> into that format. Anyone have any secrets for me?
I thought I had some answers, but there's a slight discrepency:
perl -e 'use POSIX; print mktime(0,0,12,14,4-1,2004-1900,0,0,0), "\n";'
1081962000
mysql> SELECT unix_timestamp('2004-4-14 12:00:00');
+--------------------------------------+
| unix_timestamp('2004-4-14 12:00:00') |
+--------------------------------------+
| 1081958400 |
+--------------------------------------+
YMMV :D
-- Jason
More information about the Ale
mailing list