Rickstar
Rickstar

Reputation: 6199

timestamp function Pluse 1 hour PHP

I am tring to get a set time timestamp for e.g

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

Upvotes: 0

Views: 208

Answers (2)

Pascal MARTIN
Pascal MARTIN

Reputation: 401182

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`**][2] class :
$dt = new DateTime('09:00');
$ts = $dt->format('U');
var_dump($ts);

Upvotes: 3

Jon
Jon

Reputation: 437814

Use strtotime:

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

Upvotes: 1

Related Questions