Back to Top

How to Get local time using EarthTool

To Get local time using EarthTool

Here in this quick article I am going to explain about to get local date- time using the latitude and longitude in earth tools.

However, you can display date-time as per user address in the site using below function.Here you just need to pass latitude and longitude of user address.

In Web development or website, most important is to show user actual time otherwise users get confused.

Let’s dive into the code:

Here in below function, I have called earth tools by passing latitude and longitude which returns response into XML.

function GetLocalTimeByEarthTool($latitude,$longitude)
{
    $earth_uri  = "http://www.earthtools.org/timezone/$latitude/$longitude";
    $response = simplexml_load_file($earth_uri);
    return (string)$response->localtime;
}

echo GetLocalTimeByEarthTool($lat_val,$long_val);

I hope this article is useful to someone.

Thank you for reading.Feel free to share your thoughts! Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

How to use Git init command

Posted on 1 year ago

Bhumi

How to Use PHP Sessions to Store Data

Posted on 2 years ago

Bhumi

How to use jQuery Cookie

Posted on 6 years ago

Bhumi

How to use HTML5 download attribute?

Posted on 3 years ago

Bhumi

Hello world

Updated 5 days ago

Nick Carter

In depth Understanding of Laravel Core

Updated 2 months ago

Bhumi

ECMAScript 6 New Features – 2

Updated 1 year ago

Bhumi

The Reader’s Poll – June 2015

Posted on 4 years ago

Bhumi

The Reader’s Poll – August 2014

Posted on 4 years ago

Bhumi

The Reader’s Poll – June 2014

Posted on 5 years ago

Bhumi

The Readers’ Poll – May 2014

Posted on 5 years ago

Bhumi

The Readers’ Poll – August 2013

Posted on 5 years ago

Bhumi