I am tring to get a set time timestamp for eg
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);
使用strtotime
:
$timestamp = strtotime('09:00');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.