I have created a news script (with some help) and i am having problems with the date
when i submit the news i store it with the date that it was posted on using the curdate() function
when i read from the file i want to be able to customize the format using the date() function but can't figure out how to do this, i have tried various ways and come up with some wierd answers. i tried one thing and the date came up as December 31st, `1968
does anyone know how i would do this
tia, Joejust to point out, when the script stores the date in the database it stores the correct datewhat curdate function?theres no real function by that name listed in the manual...either way...date(); takes a timestamp as it's second argument....either you need to use time(); to generate the timestamp to store or you need to store the date in a format you can use with mktime(); to generate the timestamp.So:
$date = time();
mysql_query("INSERT INTO news (posted) ('$date')");
$query = mysql_query("SELECT posted FROM news");
$row = mysql_fetch_array($query);
echo date("formatting options",$row["posted"]);
is generally a good way.i have $datetime = time(); in the submitnews file and in the actual news page i have
$datetime = date("F j, Y. g:i a",$row["dateentered"]);
and it works correctly, thanks man CURDATE() is a mysql function.the curdate() was in my INSERT query
$sql="INSERT INTO news (`name`, `subject`, `news`, `dateentered`) VALUES ('$name', '$subject', '$news', curdate())"; was what i had
when i submit the news i store it with the date that it was posted on using the curdate() function
when i read from the file i want to be able to customize the format using the date() function but can't figure out how to do this, i have tried various ways and come up with some wierd answers. i tried one thing and the date came up as December 31st, `1968
does anyone know how i would do this
tia, Joejust to point out, when the script stores the date in the database it stores the correct datewhat curdate function?theres no real function by that name listed in the manual...either way...date(); takes a timestamp as it's second argument....either you need to use time(); to generate the timestamp to store or you need to store the date in a format you can use with mktime(); to generate the timestamp.So:
$date = time();
mysql_query("INSERT INTO news (posted) ('$date')");
$query = mysql_query("SELECT posted FROM news");
$row = mysql_fetch_array($query);
echo date("formatting options",$row["posted"]);
is generally a good way.i have $datetime = time(); in the submitnews file and in the actual news page i have
$datetime = date("F j, Y. g:i a",$row["dateentered"]);
and it works correctly, thanks man CURDATE() is a mysql function.the curdate() was in my INSERT query
$sql="INSERT INTO news (`name`, `subject`, `news`, `dateentered`) VALUES ('$name', '$subject', '$news', curdate())"; was what i had