note 9994 added to getdate

From: Date: Tue, 05 Dec 2000 16:02:10 +0000
Subject: note 9994 added to getdate
Groups: php.notes 
Request: Send a blank email to php-notes+get-8421@lists.php.net to get a copy of this message
<?php There is a simple way to get getdate(); into the mySQL format: Here is an function I define as "fixDate()" function fixDate($int){ $int = ($int<10)?str_replace("0", "", $int):$int; $int = ($int<10)?"0$int":$int; return $int; } $d = getdate(); echo $d[year]."-".fixDate($d[mon])."-".fixDate($d[mday]); If you want the time in addition to the date add this line: echo " ".fixDate($d[hours]).":".fixDate($d[minutes]).":".fixDate($d[seconds]); ?> http://www.php.net/manual/function.getdate.php

« previous php.notes (#8421) next »