Generate and insert date into MySQL database using php -


I used the following code to insert the date my_table in my_table of MySQL database. It worked fine in WAMP and MAMP. But it does not work in my host. What will be the reason please help ... $ dt = new date time (); $ D = date_add ($ dt, date_interval_create_from_date_string ("- 1 day")); $ Date = $ d-> Format ('Y-M-D'); $ Import = "my_table (date) values ​​('$ date') ''; mysql_query ($ import) or INSERT (mysql_error ()) to die;

< Div class = "post-text" itemprop = "text">

Your host may not support the date time () function ...

Try date () and Stratom () functions:

  $ today = time (); $ yesterday = date () 'YMDHH: i: S', stratetime ('- 1 day', today $));    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -