Just wondering if there was a way to check the current date and time in Jquery.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In JavaScript you can get the current date and time using the Date object;
This will get the local client machine time, if you want to do timezone adjustments or get the time from a server, check my answer to this question.
Edit: In response to your comment, you can retrieve your server time to the client side very easily:
time.php:
A simple JSON string is created, with a new Date object initialized with the current server time, this value is multiplied by 1000, because PHP handles timestamps in seconds, and JavaScript does it in milliseconds.
And on your other you can get the server time like this:
Just make a getJSON request to retrieve the date from time.php, and access to the serverTime property of the returned object.