- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set current time to some other time in JavaScript?
You cannot do this with JavaScript since it takes the system time which displays the current date with Date object. However, you can change the current date by changing the timezone as in the following code −
Example
<!DOCTYPE html> <html> <body> <script> var date, offset, nd; date = new Date(); document.write("Current: "+date); utc = date.getTime() + (date.getTimezoneOffset() * 60000); // Singapore is GMT+8 offset = 8; nd = new Date(utc + (3600000*offset)); document.write("<br>Singapore Time: "+nd.toLocaleString()); </script> </body> </html>
Output
- Related Articles
- How to get current date and time in JavaScript?
- How to get current date/time in seconds in JavaScript?
- Set current date and time to timestamp in MySQL
- How to get the current time in millisecond using JavaScript?
- How to get current date and time using JavaScript?
- Forming the nearest time using current time in JavaScript
- How to extract the number of minutes from current time in JavaScript?
- How to insert current date/time in MySQL?
- How to get current Time in Java 8?
- Java Program to display Current Time in another Time Zone
- Get current date/time in seconds - JavaScript?
- How to get current time in milliseconds in Python?
- How to set default date time as system date time in MySQL?
- How to add 5 hours to current time in MySQL?
- How to get current time and date in C++?

Advertisements