Date time format
i want to set a variable to a particular date like this in php..how to write this function in php? jsmyStartDate = new Date('April 开发者_StackOverflow1, '+curYear+' 1:59:59');
do you mean
<?php
$today = date("D M j Y g:i:s e O");
echo $today;
// Thu Oct 14 2010 10:56:17 Europe/London +0100
or why not just
date('r');
take a look at date in the php manual, you're almost on the right way (just replace the R
with eO
;) ).
it looks like you want the date to be in RFC2822-format, in this case you could also simply use date("r")
.
Why is this voted down? Its simple but still...
use date("D M j Y g:i:s \G\M\TO");
(larg o at the end)
Found this on the php.net site - http://php.net/manual/en/function.date.php right at the bottom
<?php
function zonedate($layout, $countryzone)
{
if ( $countryzone >> 0 )
{
$zone = 3600 * $countryzone;
}
else
{
$zone = 0;
}
$date = gmdate($layout, time() + $zone);
return $date;
}
$layout = "D M j Y g:i:s e O";
$countryzone = 5.5;
echo zonedate($layout, $countryzone);
?>
Try something like this?
精彩评论