perl - How can I convert a date to epoch time? -
i have huge formatted file of form:
29/01/2010 18:00 string1 string2 ..... 30/01/2010 18:30 string3 string4 ..... ... ... dd/mm/yyyy hh:mm strings strings....
i need perform statistics based on dates.
so substitute string dd/mm/yyyy hh:mm
epoch time in file in order perform simple manipulations.
i suppose best way use perl, don't know start. hints?
just that? quick-and-dirty one-liner should do:
perl -mposix -pwe 's{^(\d{2})/(\d{2})/(\d{4}) (\d{2}):(\d{2}) }{mktime(0,$5,$4,$1,$2-1,$3-1900)." "}e;'
feed file on standard input , output changed version standard output. lines have "dd/mm/yyyy hh:mm " @ start, , feed date components mktime
function posix
module unix timestamp.
Comments
Post a Comment