Search:
Main Menu
Login | RSS |

Quick PHP Code Tips and Examples

PHP Programming Tips, Tutorials and Source Code Examples for newbie

Convert PHP date() and time into MySQL Date Time Field

March 14th, 2007 by Jon Moffet

Here's a quick way to convert php date() into a format acceptable to be stored in MySQL database 'Date Time' field

PHP:
  1. $date = date("Y-m-d H:i:s",time());

If you want to store the time in MySQL 'Date' field then you can use this code

PHP:
  1. $date = date("Y-m-d",time());

you can later insert $date into MySQL "Date" or "Date Time" field to be manipulated by the database later.

Example of MySQL 'Date' value :

  • 2007-03-11 18:52:42
  • 2007-03-11

Tags: , ,

Bookmark Post:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • NewsVine
  • Reddit
  • Netvouz
  • Spurl
  • Furl
  • digg
  • YahooMyWeb
  • del.icio.us

Posted in Uncategorized |

Related Posts

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.