note 46134 added to function.getdate

From: Date: Thu, 30 Sep 2004 13:01:19 +0000
Subject: note 46134 added to function.getdate
Groups: php.notes 
Request: Send a blank email to php-notes+get-77618@lists.php.net to get a copy of this message
If you want to insert a date into a mysql date field, you need to ensure it's correctly formatted else it goes in as 0000-00-00 (not good!) These two lines of code will create the variable $dt ready for insertion $dte = getdate(); $dt = $dte[year] . "-" . str_pad($dte[mon], 2, "0", STR_PAD_LEFT) . "-" . str_pad($dte[mday], 2, "0", STR_PAD_LEFT); example: 2004-09-30 ---- Manual Page -- http://www.php.net/manual/en/function.getdate.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+46134 Delete -- http://master.php.net/manage/user-notes.php?action=delete+46134&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+46134&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#77618) next »