September 6th, 2000, 08:35 PM
-
I have been reading through the posts here and found some great information, but for some reason cannot get this date function to print correctly.
I have dates stored in MySQL in the YYYY-MM-DD format and I am placing them in a string $EventStartDate in my code. I am trying to print the string in a more attractive format. Instead of 2000-09-06 I would like Wed Sep 6th, 2000.
I have found how to print the date in this format using date(), but when I use this on the string I get Weds Dec 31st, 1969. What am I doing wrong? (I know the dates are stioring correctly in the DB, I have checked that)
Here is how I am doing it:
//$EventStartDate is pulled from db
$StartDate=date("D M jS, Y",$EventStartDate) ;
print "<td>$StartDate</td>" ;
September 6th, 2000, 10:32 PM
-
date() is a PHP function for formating a unix timestamp. It has nothing to do with mysql date/time datatypes. Look in the mysql manual under date_format() for the mysql function to format the date the way you want.
September 7th, 2000, 06:27 AM
-
As an alternative you can put the UNIX-timestamp(returned by the function time() in PHP) in the database (not in a date-field but in a unsigned INT field) and then you can easily retreive the timestamp and use the date() function to format it.
Good luck,
Ramon.
------------------
Ramon Litjens
Boradoli Web Design
(www.boradoli.nl)
September 14th, 2000, 10:17 AM
-
See DBrown's post titled "Formatting a queried date datatype...how?" from Dec 31,1999 and rodk's response.