note 15043 deleted from function.getdate by jimw

From: Date: Mon, 22 Oct 2001 23:43:38 +0000
Subject: note 15043 deleted from function.getdate by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-19304@lists.php.net to get a copy of this message
A lot of people here go into str_replace , and worse, regexes to get some date into a database.. validation of user input being a separate issue, the simplest way to get a date into a mysql database is to use FROM_UNIXTIME together with a timestamp.. ex: $timestamp = time(); # or whatever $sql_string = " INSERT INTO dates ( date_1 ) VALUES ( FROM_UNIXTIME ( {$timestamp} ) ) "; no need to mess with the timestamp, let SQL handle that..

« previous php.notes (#19304) next »