Jump to content

Date Problem


wemustdesign

Recommended Posts

Hi,

 

I have the date stored in my datrabase like this:

 

2010-04-03

 

I am then outputting the date like this:

 

Sat 13 Nov

 

This is done using this code:

 

list($year,$month,$day) = explode('-',$Coursedate);

$time_stamp = mktime(0,0,0,$month,$day);

$Coursedate2 = date("D d M",$time_stamp);

 

The problem I have come across is when listing a date for next year. The database has a value of 2011-01-29 which is a Saturday but it is outputting it as a Friday:

 

Fri 29 Jan

 

The 29th of January 2010 is a Friday but 2010 is a Saturday.

 

Any idea what is wrong with the code?

Link to comment
https://forums.phpfreaks.com/topic/216554-date-problem/
Share on other sites

quoted from - http://forums.devarticles.com/mysql-development-50/mysql-datetime-w-php-7624.html

 

There's a few different solutions... first of all, you could format the actual return result using the SQL statement...

 

SELECT DATE_FORMAT(date_field, '%W, %y.%m.%e @ %h:%i %p') FROM table

 

Refer to this: http://www.mysql.com/doc/en/Date_an..._functions.html

 

 

Or you could try the PHP date functions:

http://ca3.php.net/manual/en/function.date.php

 

--------------------------------------------------------------------------------

 

 

Link to comment
https://forums.phpfreaks.com/topic/216554-date-problem/#findComment-1125180
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.