How can I get the timestamp for tomorrow 00h10?

16,314

Solution 1

Simply

echo date("Y-m-d 00:10",strtotime('tomorrow'))

However in your code the error is the use of H:s instead of H:i

From doc:

i: Minutes with leading zeros | 00 to 59

s: Seconds, with leading zeros | 00 through 59

Solution 2

just add 10 minutes:

$timestamp = strtotime('tomorrow +10min');
Share:
16,314
Gottlieb Notschnabel
Author by

Gottlieb Notschnabel

Updated on July 22, 2022

Comments

  • Gottlieb Notschnabel
    Gottlieb Notschnabel almost 2 years

    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?

  • Gottlieb Notschnabel
    Gottlieb Notschnabel over 10 years
    Yeah, also does the job. But my problem was somewhere else. Thanks anyway!