Jump to content

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


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...

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.