Function : Converts a local Unix timestamp to GMT

0saves

Convert Local UNIX Timestamp to GMT

This function converts local unix timestamp to GMT time format.  It accepts local unix timestamp as input parameter. This is very simple function made using php time and date functions.

..


// ------------------------------------------------------------------------
/**
 * Converts a local Unix timestamp to GMT
 *
 * @param    integer Unix timestamp  = $time
 * @return    integer
 */
if ( ! function_exists('local_to_gmt'))
{
 function local_to_gmt($time = '')
 {
 if ($time == '')
 $time = time();

 return mktime( gmdate("H", $time), gmdate("i", $time), gmdate("s", $time), gmdate("m", $time), gmdate("d", $time), gmdate("Y", $time));
 }
}

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Related Posts

About the Author: Abhishek Sanghvi

Hi Friends, my name is Abhishek Sanghvi and I am the founder of this “open source script” site MYPHPSCRIPTZ. I have been learning and practising PHP from the last 3 years. You could always contact me if you wish to have some code for your need. I would surely try and solve them for you at abhishek(at)myphpscriptz(dot)com

5 Comments + Add Comment

Leave a comment


+ seven = thirteen

CommentLuv badge