get strtotime of specific time in php

前端 未结 2 1210
盖世英雄少女心
盖世英雄少女心 2021-01-13 03:03

I want to get the timestamp of a day/time for eg

17/12/2014 8pm

Currently I am doing

$curtime = strtotime(date(\"Y-m-d H:i:         


        
2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-13 03:12

    The best way to do this is using date_create_from_format. Checking out format's parameters, you will end up with something like this:

        $date = date_create_from_format('d/m/Y ga', '17/12/2014 8pm');
        if (!empty($date)) {//returns false if can't create date
            $timestamp = $date->getTimestamp();
            //echo date('d/m/Y H:i:s', $timestamp);
        }
    

提交回复
热议问题