How do I convert a date/time to epoch time (unix time/seconds since 1970) in Perl?

前端 未结 13 2209
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-03 04:20

Given a date/time as an array of (year, month, day, hour, minute, second), how would you convert it to epoch time, i.e., the number of seconds since 1970-01-01 00:00:00 GMT?

13条回答
  •  忘掉有多难
    2020-12-03 04:59

    My favorite datetime parser is DateTime::Format::ISO8601 Once you've got that working, you'll have a DateTime object, easily convertable to epoch seconds with epoch()

提交回复
热议问题