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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.