downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

DateTime::setTimezone> <DateTime::setTime
Last updated: Fri, 14 Aug 2009

view this page in

DateTime::setTimestamp

(PHP 5 >= 5.3.0)

DateTime::setTimestampAssigne la date et l'heure à l'aide d'un timestamp Unix

Description

public DateTime DateTime::setTimestamp ( int $unixtimestamp )

Assigne la date et l'heure à l'aide d'un timestamp Unix.

Liste de paramètres

unixtimestamp

Timestamp Unix représentant la date et l'heure.

Valeurs de retour

Retourne l'objet DateTime modifié.

Voir aussi



add a note add a note User Contributed Notes
DateTime::setTimestamp
edwin dot h at clear dot net dot nz
01-Oct-2009 08:55
If you are using PHP < 5.3.0 you can use this function instead:

<?php
function DateTime_setTimestamp(&$dt,$timestamp) {
$dtz_original = $dt -> getTimezone();
$dtz_utc = new DateTimeZone("UTC");
$dt -> setTimezone($dtz_utc);
$year = gmdate("Y",$timestamp);
$month = gmdate("n",$timestamp);
$day = gmdate("j",$timestamp);
$hour = gmdate("G",$timestamp);
$minute = gmdate("i",$timestamp);
$second = gmdate("s",$timestamp);
$dt -> setDate($year,$month,$day);
$dt -> setTime($hour,$minute,$second);
$dt -> setTimezone($dtz_original);
}
?>

DateTime::setTimezone> <DateTime::setTime
Last updated: Fri, 14 Aug 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites