Jump to content


Can't understand how to get date_format to work!

  • Please log in to reply
No replies to this topic

#1 Avalanche

  • Members
  • PipPipPip
  • Advanced Member
  • 73 posts

Posted 09 April 2003 - 02:53 AM

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?

DEFINE("YOU","Spending Too Much Time On The Computer");

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users