Jump to content


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


Can't understand how to get date_format to work!

Recommended Posts

Okay, here is my code:




include \"config.php\";


$db = mysql_connect($db_host,$db_user,$db_pass);

mysql_select_db ($db_name) or die (\"Cannot connect to database\");

/* We have now connected, unless you got an error message */

/* Lets post some news ! */

$query = \"INSERT INTO news(title, news, author, date)

VALUES(\'\".$_POST[\'title\'].\"\',\'\".$_POST[\'news\'].\"\',\'\".$_POST[\'author\'].\"\', now())\";


echo \"<b>Your entry has been successfully added.</b><p>\";





As you can see, it inserts \"now()\" as the date (which is the current date in MySQL, which I\'m sure you know).


It comes out: 2003-04-09


I need to do two things:

1) Set the GMT offset to -5 (I posted it the 8th here and it says it\'s the 9th)

2) Reformat it to say April 8th, 2003


I\'ve tried using the date_format thing but I can\'t quite get it to work. Could you give me a snippet of code to get it to work properly given my code?



Share this post

Link to post
Share on other sites


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.