Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the timestamp for tomorrow 00h10?

Tags:

date

php

time

To prevent misunderstandings: All my code lines where fine, and they work correctly. I just had a wrong parameter in my date(), where I displayed the seconds date('H:s'), where it should've displayed the minutes as date('H:i'). (Thanks to chumkiu for the hint.)


I want to fetch the timestamp for the upcoming day at 00h10.

I thought I could use the strtotime() function, e.g. like

$timestamp = strtotime('tomorrow 00:10');

But when I check

$mydate = date('Y-m-d H:s', $timestamp);
var_dump($mydate);

the output is

string(16) "2013-10-03 00:00"

The documentation of strtotime() has a lot of examples how to get different times

echo strtotime("now"), "\n";
echo strtotime("10 September 2000"), "\n";
echo strtotime("+1 day"), "\n";
echo strtotime("+1 week"), "\n";
echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n";
echo strtotime("next Thursday"), "\n";
echo strtotime("last Monday"), "\n";

But none of them comes close to my problem.

Funny enough: I can do this

$time_h = strtotime('tomorrow +10 hours');
$time_m = strtotime('tomorrow +10 minutes');

whereas $time_h returns the wanted result (10:00), but $time_m does not.

Any ideas?

like image 350
Gottlieb Notschnabel Avatar asked Oct 02 '13 11:10

Gottlieb Notschnabel


1 Answers

just add 10 minutes:

$timestamp = strtotime('tomorrow +10min');
like image 177
kelunik Avatar answered Oct 16 '22 12:10

kelunik