Re: Re:Date->TimeStamp
| From: | James, Yz | Date: | Sat, 20 Oct 2001 13:21:10 +0000 |
| Subject: | Re: Re:Date->TimeStamp | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-71675@lists.php.net to get a copy of this message | ||
Hi Daniel,
Try this:
<?
function DateToTimestamp($datetime) {
list ($date, $time) = explode(" ", $datetime);
list ($year, $month, $day) = explode("-", $date);
list($hour, $minute, $second) = explode(":", $time);
$timestamp = mktime($hour, $minute, $second, $month, $day, $year);
return $timestamp;
}
echo DateToTimestamp("2001-10-20 14:05:15");
?>
Should work ok.
James
"Daniel Harik" <http404@hot.ee> wrote in message
news:1347590093.20011020091005@hot.ee...
> I've tried this code:
>
> $timea = explode(" ",$timepostsed);
> $timea1 = explode("-",$timea[0]);
> $timea2 = explode(":",$timea[1]);
> $timestamp =
> mktime($timea2[0],$timea2[1],$timea2[2],$timea1[1],$timea1[2],$timea1[0]);
>
>
> But it return "-1"
>