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 1, '+curYear+' 1:59:59');
views:
43answers:
4
+1
A:
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")
.
oezi
2010-10-14 09:56:27
Nearly there, except for the written out Time zone identifier. That seems to be `date("r e");`
Pekka
2010-10-14 09:57:39
+2
A:
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');
Ross
2010-10-14 09:56:43
@ross thanks. i want to extract year from $today,something like this $year=date($today); is this correct?
mayuri
2010-10-14 10:02:35
`$today = date("D M j Y g:i:s e O");``$year=date("Y", strtotime($today));``echo $year; //2010 -` gets the year from the original date.
Ross
2010-10-14 10:34:17
i want to set a variable to a particular date like this in php..js: myStartDate = new Date('April 1, '+curYear+' 1:59:59');how to write this function in php?
mayuri
2010-10-14 13:01:09
A:
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)
Hannes
2010-10-14 10:00:40
A:
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?
etbal
2010-10-14 10:03:43