mayuri
mayuri

Reputation: 129

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 1, '+curYear+' 1:59:59');

Upvotes: 0

Views: 352

Answers (4)

Etienne Marais
Etienne Marais

Reputation: 1690

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?

Upvotes: 0

Hannes
Hannes

Reputation: 8247

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)

Upvotes: 0

Ross
Ross

Reputation: 17987

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');

Upvotes: 2

oezi
oezi

Reputation: 51817

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").

Upvotes: 1

Related Questions