phpstrtotimetimeslots

I want to get the timestamp of next day 12PM in PHP


i want to get the timestamp of tomorrow at 12PM, i can do this using the line of code below

strtotime('tomorrow noon');

But the problem am having is that, when the current time is 00:00 at midnight, am getting the next day timestamp, i want it such when the time is 00:00 at midnight, it should still give the timestamp of noon of the new day not the next day.


Solution

  • I'm imagining you might like to display the current day at noon if it is not yet noon, otherwise show the time tomorrow at noon. If this is the case, the following might be helpful:

    $noon = strtotime('now') < strtotime('noon') 
    ? strtotime('noon') 
    : strtotime('tomorrow noon')