date_timestamp_set


php apg

SETS the date and time according UNIX timestamp.



<?php

/* - - - - - - - - - - - - - - - - -

    Object oriented style
   
   - - - - - - - - - - - - - - - - - */

DateTime public DateTime::setTimestamp int $timestamp )


where,

$unixtimestamp The UNIX timestamp 

?>

<?php

/* - - - - - - - - - - - - - - - - -

      Procedural style
   
   - - - - - - - - - - - - - - - - - */

DateTime date_timestamp_set DateTime $object int $timestamp )


where,

$object A DateTime object

$unixtimestamp 
The UNIX timestamp 

?>

 $object 


A DateTime object.



 $unixtimestamp 


The UNIX timestamp.





For Procedural style, only: A DateTime object returned by the function like date_create.

The function modifies this object.

The DateTime object for method chaining or FALSE on failure.



  1 EXERCISE   

<?php

date_default_timezone_set
("UTC");

$dftz011 date_default_timezone_get();

echo 
'<br><span class="destaque">' $dftz011 '</span><br><br>';

$dtms011 = new DateTime();

$dtms011->setTimestamp(0);

echo 
$dtms011->format('B => (U) => T Y-M-d H:i:s');

// Beginning of UNIX ERA

?> 

  2 EXERCISE   


<?php

date_default_timezone_set
("America/New_York");

$dftz021 date_default_timezone_get();

echo 
'<br>' $dftz021 '<br><br>';

$dtms021 date_create();

date_timestamp_set($dtms0211234567890);

echo 
date_format($dtms021'B => (U) => T Y-M-d H:i:s');

?> 

  3 EXERCISE   


<?php

date_default_timezone_set
("Asia/Tokyo");

$dftz031 date_default_timezone_get();

echo 
'<br>' $dftz031 '<br><br>';

$dtms031 date_create();

$ts031 time();

date_timestamp_set($dtms031$ts031);

echo 
date_format($dtms031'B => (U) => T Y-M-d H:i:s');

?>