Jump to content

MDT to GMT date/time help


RazorMaster

Recommended Posts

Hi,

 

I need to convert MDT time to GMT time.

I have this php code to output a date/time format:

 

$example[$count]['startdate'] = date("j/n/Y", $info['example_start']);

 

The output for this is: 23/05/2008 07:00 MDT

But I need this is GMT (0): 23/05/2008 14:00 GMT

 

The ['example_start'] is a unix date/time.

I just can't understand how to use mktime() or gmmktime() in here to output correct timezone date/hour...

 

Any help?

Thanks.

Link to comment
Share on other sites

<?php
$hour = date("G") + 7;
$minute = date("i");
if ($hour >= 24){
$hour = $hour - 24; //converts it to the next day
$day_increment = 1; //add a day
}
else {
$day_increment = 0;
}
$day = date("j") + $day_increment;
$month = date("n");
$year = date("Y");
$numberOfDays = date("d", mktime(0, 0, 0, $month + 1, 0, $year));
if ($day > $numberOfDays){
$day = 1;
$month = $month + 1;
if ($month > 12){
	$month = 1;
	$year = $year + 1;
}
}
$date = $day."/".$month."/".$year." ".$hour.$minute;
print $date;
?>

Link to comment
Share on other sites

Well, the first option just give me the actual date/time and is not converting the unix date/time posted...

The second option works just fine...

 

But, how to convert this???

$example[$count]['example_timezone'] = date("T", $info['example_time']);

 

This is returning "MDT" instead "GMT".

Any chance to convert this???

 

PS: Thanks a lot to jonsjava... Its a great code to display actual date/time in GMT timezone...

Link to comment
Share on other sites

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.