Datestamp:
Jul 9 2009 11:55 PM
how can I convert it to epoch?
I know of several ways: str2time() and DateTime (I'm sure there are many other ways but these are the two I usually use). Both of these 2 ways don't work for me.
str2time doesn't work because I'm not able to pass a timezone to it (look in the BUGS section at the bottom of the page):
http://search.cpan.org/~rse/lcwa-1.0.0/lib/lwp/lib/HTTP/Date.pm
Passing in digits, like "-0900" for instance, does not work for me because daylight savings time will screw it up each time (digits will change so somebody will need to modify the script.. this needs to be avoided)
DateTime doesn't work because I can't construct an AM/PM time in there, it can only handle military time.
I'm looking for something like str2time() but it needs to be able to parse that date format (str2time knows a LOT of date formats) AND accept a standard UNIX timezone like "Asia/Tokyo" or "America/New_York" or whatever.
Any suggestions?
UPDATE: It just occured to me that I can construct a hash, something like:
my %mil_time = (); $mil_time{ 1 } = "13" $mil_time{ 2 } = "14" $mil_time{ 3 } = "15" ...
and then I can beat the date format into submission and have it work with DateTime by checking if the datestamp is PM, and if it is, replace the hour with the key's value from %mil_time.
Hm. This would be a lot of typing. :) Still looking for suggestions / comments / whatever.
In reply to Datestamps/epochs and other fun stuff by vxp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |