About date & time...
| From: | Gustav Wiberg | Date: | Tue, 28 Feb 2006 13:33:34 +0000 |
| Subject: | About date & time... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-231198@lists.php.net to get a copy of this message | ||
Hi
Thanx for your input about date & time...
Here's some functions that worked for me after some searching...
function currenttime() {
$today = getdate();
$ithours = $today["hours"];
if (intval($ithours)<10) {
$ithours = "0" . $ithours;
}
$itminutes = $today["minutes"];
if (intval($ithours)<10) {
$ithours = "0" . $ithours;
}
$itseconds = $today["seconds"];
if (intval($itseconds)<10) {
$itseconds = "0" . $itseconds;
}
$it = $ithours . ":" . $itminutes . ":" . $itseconds;
return $it;
}
function currentdate() {
$today = getdate();
$idyear = $today["year"];
if (intval($idyear)<10) {
$idyear = "0" . $idyear;
}
$idmonthnr = $today["mon"];
if (intval($idmonthnr )<10) {
$idmonthnr = "0" . $idmonthnr ;
}
$idmonthday = $today["mday"];
if (intval($idmonthday)<10) {
$idmonthday = "0" . $idmonthday;
}
$id = $idyear . "-" . $idmonthnr . "-" . $idmonthday;
return $id;
}
$insertTime = currenttime();
$insertDate = currentdate();
/G