Lewis Day Lewis Day - 1 year ago 60
PHP Question

convert a date into a timestamp

Okay so basically I have two variables one called

and another called
what I'm trying to do is convert both of these into a unix time-stamp so for example;

$day = 'Monday';
$time = '14:00:00';

So what I'm looking for is a
variable that would echo out the next
coming up at
in a unix timestamp format.

I'm guessing the hardest part of this would be the fact that the day is not a specific date more a day of the week meaning it would have to select the next
coming up, or the next
for example.

Thanks for any help.

Answer Source

The constructor for the DateTime class is pretty good at figuring this sort of thing out:

$day = 'Monday';
$time = '14:00:00';

$date = new DateTime("next $day $time");
echo $date->getTimestamp();
// 1475503200
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download