SHARE
TWEET

UTC time in PHP

TringaliLuca Mar 11th, 2019 12 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $zone = "";
  4. $zone = $_GET["zone"];
  5. if ($zone == "") $zone = 'Europe/Rome';
  6.  
  7. date_default_timezone_set('UTC');
  8. $dt = date('d/m/Y H:i:s');
  9.  
  10. print '<'.date_convert($dt, 'UTC', 'd/m/Y H:i:s', $zone, 'd/m/Y H:i:s').'>';
  11. //print "<27/10/2016 13:12:02>";
  12.  
  13. function date_convert($dt, $tz1, $df1, $tz2, $df2) {
  14.   $d = DateTime::createFromFormat($df1, $dt, new DateTimeZone($tz1));
  15.   $d->setTimeZone(new DateTimeZone($tz2));
  16.   return $d->format($df2);
  17. }
  18.  
  19. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top