开发者

timestamp function Pluse 1 hour PHP

I am tring to get a set time timestamp for e.g开发者_如何学Python

if I input the follow time 09:00 i want to see the timestamp for today

function GetTimestamp($time){
date();
}

return GetTimestamp("09:00")

can someone help me please or lead me down the right path


You just have to use the strtotime() function, passing it your time :

$ts = strtotime('09:00');
var_dump($ts);

And you'll get :

int 1300435200


Note : if you don't specify the date, strtotime will use today.


You could also use the DateTime class :

$dt = new DateTime('09:00');
$ts = $dt->format('U');
var_dump($ts);


Use strtotime:

$timestamp = strtotime('09:00');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜