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

前端 未结 13 2150
爱一瞬间的悲伤
爱一瞬间的悲伤 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:45

    $ENV{TZ}="GMT";
    POSIX::tzset();
    $time = POSIX::mktime($s,$m,$h,$d,$mo-1,$y-1900);
    

提交回复
热议问题