RE: [PHP] Date Format on a timestamp field
| From: | Jason Murray | Date: | Tue, 28 Nov 2000 07:59:58 +0000 |
| Subject: | RE: [PHP] Date Format on a timestamp field | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-27564@lists.php.net to get a copy of this message | ||
> <? echo
> date("d/m/Y",$GetApplicationDetailRow[$IndApplicationDate]);?>
> This does not give me an error message, but rather
> gives me the date value of:01/01/1970
> which should actually hold the date value:08/05/2000
> from a field in the database.
This would be because:
date("d/m/Y",$GetApplicationDetailRow[$IndApplicationDate]);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Isn't evalutating to a unix timestamp. This would mean your date isn't in
that
variable.
> And this:<? echo
> $GetApplicationDetailRow[$IndApplicationDate];?> gives
> me the right value but in the wrong format
> ie:08/05/2000 00:00:00
Okay ... try this:
$mystuff = $GetApplicationDetailRow[$IndApplicationDate]; // I hate long var
names
$day = substr($mystuff, 0, 2);
$month = substr($mystuff, 3, 2);
$year = substr($mystuff, 6, 4);
$hour = substr($mystuff, 12, 2);
$minute = substr($mystuff, 15, 2);
$second = substr($mystuff, 18, 2);
$unixtime = mktime($hour, $minute, $second, $month, $day, $year);
$output = date("d/m/Y", $mystuff);
See how that goes. I don't know if you're using english or american
date format, you may need to change the lines that get the day and the
month above.
Jason