0

I'm trying to get the minutes until 00:00:00 (until the day changes) but in Chicago timezone. I set my timezone to chicago (temporarly) then reset it to my original. There thing I am currently struggling with is getting the amount of minutes until the day changes. I need the minutes as I am trying to set a cookie that will expire as soon as it turns tomorrow.

$oldTimezone = date_default_timezone_get();
date_default_timezone_set('America/Chicago');
// TODO: Get the minutes while Chicago is active.
date_default_timezone_set($oldTimezone);
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
hello
  • 169
  • 10
  • 1
    Don't you set the cookie `expires` property to [_"date-in-GMTString-format"_](https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie#Syntax)? – Phil Feb 01 '18 at 05:01
  • 1
    You need to get into the habit of accepting answers. You'll earn good reputation at the same time. – Funk Forty Niner Feb 02 '18 at 14:40

1 Answers1

4

Here you go:

echo (strtotime('tomorrow') - strtotime('now')) / 60;

Note: This is not a formatted string, if you wish to format in H:i:s, this will work:

echo date("H:i:s", (strtotime('tomorrow') - strtotime('now')));
Aniket Sahrawat
  • 12,410
  • 3
  • 41
  • 67