I am trying to create a simple application that will allow users to search for two locations and the time difference of two locations will be displayed to them.
I can get the two location Offset using the code bellow but I cannot hook it up to the form inputs so the users can choose the locations!
Here is what I have done so far:
<form id="form1" name="form1" method="post" action="<?php $get_timezone_offset ?>">
<label>
<input type="text" class="timezone1" id="timezone1" name="timezone1" id="timezone1" />
<input type="text" class="timezone2" id="timezone2" name="timezone2" id="timezone2" />
<input name="" type="button" value="submit" />
</label>
</form>
<?php
function get_timezone_offset( $origin_tz, $remote_tz ) {
$timezone1 = new DateTimeZone( $origin_tz );
$timezone2 = new DateTimeZone( $remote_tz );
$datetime1 = new DateTime("now", $timezone1);
$datetime2 = new DateTime("now", $timezone2);
$offset = $timezone1->getOffset($datetime1) - $timezone2->getOffset($datetime2);
return $offset;
}
$offset = get_timezone_offset( 'Europe/London', 'Asia/Shanghai' );
// convert offset to hours
echo $offset/3600;
?>
any help would be appreciated.