get strtotime of specific time in php

前端 未结 2 1208
盖世英雄少女心
盖世英雄少女心 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:11

    If you're trying to get a timestamp of today at 8pm, it's actually much more simple than using date since you can use relative times in a strtotime:

    $curtime = strtotime('today 8pm');
    

    If you test this with date:

    echo date('Y-m-d H:i:s', $curtime); // Returns 2014-12-17 20:00:00
    

    Here's a whole writeup on relative date formats that explains how you can construct proper relative dates.

提交回复
热议问题