How to convert date to timestamp in PHP?

前端 未结 19 2403
暗喜
暗喜 2020-11-22 05:38

How do I get timestamp from e.g. 22-09-2008?

19条回答
  •  爱一瞬间的悲伤
    2020-11-22 06:14

    There is also strptime() which expects exactly one format:

    $a = strptime('22-09-2008', '%d-%m-%Y');
    $timestamp = mktime(0, 0, 0, $a['tm_mon']+1, $a['tm_mday'], $a['tm_year']+1900);
    

提交回复
热议问题