0

Today 05/18/2011 If i do

echo date("H:i m/d/Y", strtotime("tomorrow"));

i get 00:00 05/19/2011 as it should be but if i use the same function in setcookie like:

setcookie("wls_yesterday_review", 'completed', strtotime('tomorrow'),'/','myhost.com');

My cookie will expire on 05/18/2011 at 09:00PM

Im not sure what im doing wrong but i tested different ways and different times and i always get the same result

i want to expire the cookie at 00:00 of the following day. If today is 05/18 10:00am i want it to expire on 05/19 00:00

Thanks guys

2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by chifliiiii
0

Yep, same here with your code, I get 00:00 with echo, and when I check the cookie, I get 23:00 (i.e. 1 hour before). As we are currently in DST mode in the UK, I wonder whether this has got anything to do with it.

Are you at a different timezone to GMT/UTC? I noticed Buenos Aires is [GMT/UTC - 3 hours]. Is this why? It follows the same pattern as I get in that case 00:00 05/19/2011 - 3 hours = 5/18/2011 at 09:00PM.

//EDIT
Ah, just thought, does the pc have to have a 'standard time' cookie? Seeing as webpages can change their timezones easily, there must be a standard/uniform way of timing the expiry of cookies. So, I assume that's it. I shall have to investigate further.

Edited by diafol: n/a

0

Hi, yes im in GTM -3 and its probably what you say, but im not sure why or how to avoid the problems as users will have different time zones.

The problem is that cookies should act the same way as the echo does. In that case we will be all happy :D
I will investigate aswell.

0

Huh, would you believe it, my page was set to 'Europe/Berlin' when I tested it with

date_default_timezone_get()

Change the TZ using:

date_default_timezone_set('America/Buenos_Aires');

See if it does the trick, it did for me.

0

But in that case it will only work for America /Buenos aires people.
What about if i have an australian visitor ? How can i be sure that the cookie will expire at the end of his day and not at the end of mine ?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.