Skip to content

Instantly share code, notes, and snippets.

@chetansatasiya
Created April 10, 2018 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chetansatasiya/4c87e711048afb83d4316105c6616bed to your computer and use it in GitHub Desktop.
Save chetansatasiya/4c87e711048afb83d4316105c6616bed to your computer and use it in GitHub Desktop.
Convert one timezone to another timezone
<?php
function convert_time_one_timezone_to_other_timezone( $current_timezone = '', $time = '', $convert_to_timezone = 'EST' ) {
$utc_date = DateTime::createFromFormat(
'G:i',
"$time",
new DateTimeZone("$current_timezone")
);
$acst_date = clone $utc_date; // we don't want PHP's default pass object by reference here
$acst_date->setTimeZone(new DateTimeZone("$convert_to_timezone"));
return $acst_date->format('h:ia T');
}
$est_time = convert_time_one_timezone_to_other_timezone("Europe/Stockholm","12:00",'EST');
@ayebare
Copy link

ayebare commented Apr 10, 2018

I did some work on this some time, will send you the code

@chetansatasiya
Copy link
Author

@ayebare Thanks bro I am waiting for your response 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment