Jump to content

Hi, how to convert a date to a GMT date ?


jd2007

Recommended Posts

I came across this while browsing the net:

If you want to define your own time without having trouble with the server time you could do this;

<?php
  $timeZoneOffset = +1; //timezone where the user is (use an additional script to determine this variable)

  $H = (date('H')+date('O'))+$timeZoneOffset; //hour
  $i = date('i'); //minutes
  $s = date('s'); //seconds
  $m = date('m');  //month
  $d = date('d') //day
  $Y = date('Y') //year
  $date = date('Y-m-d, H:i:s',mktime($H,$i,$s,$m,$d,$Y)); // will output somthing like 2007-09-13, 03:52:05
?>

 

Regards ACE

If your starting from scratch or just using unix time (best), to display you can easily format with date:

$time = time();
echo date("m:d:y@G:i:s", $time);
echo date("j \of F Y, \a\\t g.i a", $time);
echo date("r", $time);

See http://uk3.php.net/manual/en/function.date.php for details...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.