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
https://forums.phpfreaks.com/topic/106932-mdt-to-gmt-datetime-help/
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;
?>

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

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.