Jump to content

Can't understand how to get date_format to work!


Avalanche

Recommended Posts

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.

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.