I need get a timestamp in PHP for the next day 6pm CST
$tomorrow = mktime(18, 0, 0, date("m"), date("d")+1, date("y"));
echo "Tomorrow is ".date("Y-m-d H:m:s ", $tomorrow);
I was unable to set the minutes part for the above code, it is always returning 11 in the minutes part.
Tomorrow is 2009-11-06 18:11:00
in your date format Y-m-d H:m:s
you are showing the month twice m
. use i
for minutes with leading zeros: Y-m-d H:i:s
(PHP Doc)
A simpler version is to use strtotime()
:
echo "Tomorrow is ".date("Y-m-d H:i:s ", strtotime("Tomorrow 6pm"));
including correcting the minutes (from m to i). Output:
Tomorrow is 2009-11-06 18:00:00