Page 1 of 1
Textual date is displaying wrong day
Posted: Wed Sep 08, 2010 7:38 am
by Vaughanjb
Hey Everybody,
I have the Day being displayed on my site and for some reason it's 2 days behind. Any help.
My code looks like this.
Code: Select all
<? echo date("l", strtotime($rowE['date'])); ?>
Any help would be great.
Thanks Vaughanjb
Re: Textual date is displaying wrong day
Posted: Wed Sep 08, 2010 7:49 am
by requinix
If it's displaying two days behind then $rowE['date'] is two days behind. Figure out why that is.
Re: Textual date is displaying wrong day
Posted: Wed Sep 08, 2010 9:03 am
by Vaughanjb
I've checked the dates. They are all correct.
For example
date = 08/09/2010
day should = Wednesday
but on my site it displays Monday
Any ideas?
Re: Textual date is displaying wrong day
Posted: Wed Sep 08, 2010 9:36 am
by pickle
I'm guessing your date is day/month/year, but strtotime() is expecting month/day/year. The 9th of August was indeed a Monday.
Re: Textual date is displaying wrong day
Posted: Wed Sep 08, 2010 9:57 am
by Vaughanjb
Ahhhh, problem found. Thanks pickle.
Is there anyway to make it work from this date or is it best just to change the date during input?
Thanks
Vaughanjb
Re: Textual date is displaying wrong day
Posted: Wed Sep 08, 2010 10:00 am
by pickle
well generally only the United States uses the month/day/year format, so if you're asking users to enter the date & they're generally not from the US, that'll confuse them. If you're using a Javascript Datepicker, it doesn't really matter though. If it won't have an adverse affect on your users, I'd change it. Otherwise, keep it as is & just change it in code somewhere.
Re: Textual date is displaying wrong day
Posted: Wed Sep 08, 2010 10:03 am
by Vaughanjb
Cheers for all your advice pickle.
Just going to change it in the code.
Thanks again.
Your a credit to this site.
Re: Textual date is displaying wrong day
Posted: Wed Sep 08, 2010 10:09 am
by pickle
Glad to help.
Re: Textual date is displaying wrong day
Posted: Wed Sep 08, 2010 12:44 pm
by AbraCadaver
FYI, the separators change the format:
Code: Select all
echo date("l", strtotime('08-09-2010'));
Wednesday