is possible to know the local time and date of the user who opens a php page? (not开发者_StackOverflow社区 server side time and date). If the answer is no, can show me an example of javascript combined with php? (im not a java developer) Thanks.
First, Java is not JavaScript…
And you could do this through hidden <input>
in HTML.
<input id="user-time" name="user-time" type="hidden" />
and JavaScript function to associate with form on submit:
function submit() {
document.getElementById("user-time").value = (new Date()).getTime();
}
After this, parse the timestamp in your server-side PHP.
Yes but it wouldn't be a 100% accurate. Using their IP you can determine what timezone they are in. See this question about doing just that.
Once you have their timezone you can use date_timezone_set to set the appropriate timezone in PHP and pull their date/time information.
精彩评论