|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2019-04-12 20:01 UTC] vinodh dot basavani at darwinbox dot io
 Description:
------------
<?php
$dt = new DateTime("1970-01-01 ".date("H:i:s"));
$dt->setTimezone(new DateTimeZone('UTC'));
echo $dt->format('r');
echo "\n";
$seconds = (int)$dt->getTimestamp();
echo date("H:i:s",$seconds);
echo "\n";
?>
even if i am setting the timezone to UTC, it is taking only the server time.
Expected result:
----------------
It should take the UTC time zone.
Actual result:
--------------
It should take the UTC time zone.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 06:00:01 2025 UTC | 
$dt = new DateTime("1970-01-01 ".date("H:i:s"), new DateTimeZone('UTC')); $seconds = (int)$dt->getTimestamp(); echo date("H:i:s",$seconds); This snippet works fine in earlier versions of php i.e it is not taking the server time zone. but when i updated to the specified version. it is always taking the server time and ignoring the timezone specified.