I am trying to get the time of the user and have been experimenting with timestamp but found it to display inaccurate time unless I set the timezone to that particular state but this method seems tedious for setting all the states in the world.. I have seen some website where they allow the user to select their GMT timezone.... how is this done in php?
Asked
Active
Viewed 71 times
0
-
1What you mean with "inaccurate" time? – Alberto Oct 11 '18 at 08:04
-
By "inaccurate" do you mean server time? Your best bet would be to use JavaScript to get the client's time. – Script47 Oct 11 '18 at 08:05
-
Welcome. PHP is run server-side, you'll have a hard time getting "the time of the user" (client-side) using PHP. – brombeer Oct 11 '18 at 08:05
-
Visit this url for get timezone https://stackoverflow.com/a/10103105/9266700 – Shubham Azad Oct 11 '18 at 08:19
1 Answers
0
var now = new Date();
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
The JavaScript Date object supports a number of UTC (universal) methods, as well as local time methods. UTC, also known as Greenwich Mean Time (GMT), refers to the time as set by the World Time Standard. The local time is the time known to the computer where JavaScript is executed. Invoking JavaScript Date as a function (i.e., without the new operator) will return a string representing the current date and time.

TsV
- 629
- 4
- 7