• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
date problem

#1
[eluser]junaids[/eluser]
hi.
i m saving some data to the database along with the current date. the date field in the DB is datetime. in my model i m writing a query like:
Code:
$time = time();
$query = "INSERT INTO news(News_headline, News_date)
    VALUES ('$newsheadline', '$time')";
$this->db->query($query);

but in the DB the date is always inserted like: 0000-00-00 00:00:00

what m i doing wrong?

#2
[eluser]me_not_you[/eluser]
do a echo on time()...it will give you something like 1243438052

=> your not giving it the right format....

#3
[eluser]Dam1an[/eluser]
with datetime fields, I always use date('c')

#4
[eluser]Thorpe Obazee[/eluser]
I've always used
Code:
date("Y-m-d G:i:s")
so PHP 4 Smile


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.