Avalanche Posted April 9, 2003 Share Posted April 9, 2003 Okay, here is my code: [php:1:56cc0e10e8]<?php 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())\"; mysql_query($query); echo \"<b>Your entry has been successfully added.</b><p>\"; mysql_close($db); ?>[/php:1:56cc0e10e8] 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? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/325-cant-understand-how-to-get-date_format-to-work/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.