
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Display the Asian and American Date Time with Date Object in JavaScript
For this, you can use timeZone from JavaScript i.e. specific time zones for Asia and America respectively.
For Asian Time Zone
var todayDateTime = new Date().toLocaleString("en-US", {timeZone: "Asia/Kolkata"});
For American Time Zone
var americaDateTime = new Date().toLocaleString("en-US", {timeZone: "America/New_York"});
Example
var todayDateTime = new Date().toLocaleString("en-US", {timeZone: "Asia/Kolkata"}); todayDateTime = new Date(todayDateTime); console.log("The Asia Date time is="); console.log(todayDateTime) var americaDateTime = new Date().toLocaleString("en-US", {timeZone: "America/New_York"}); americaDateTime = new Date(americaDateTime); console.log("The America Date time is="); console.log(americaDateTime);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo193.js.
Output
This will produce the following output −
PS C:\Users\Amit\javascript-code> node demo193.js The Asia Date time is= 2020-08-08T08:44:50.000Z The America Date time is= 2020-08-07T23:14:50.000Z
- Related Questions & Answers
- Display nanoseconds with Java Date and Time Conversion Character
- Display entire date time with milliseconds in Java
- Display seconds since the epoch with Java Date and Time Conversion Character
- Java Program to Display current Date and Time
- Java Program to display date and time in Milliseconds
- How to display date and time picker in ReactNative?
- Explain the Date() object in JavaScript?
- Display complete date and time information using Formatter in Java
- Java Program to display date and time information in lowercase
- Java Program to display date and time information in uppercase
- Python Pandas - Get the current date and time from Timestamp object
- How to create JavaScript Date object from date string?
- Set the Date and Time with Gregorian Calendar in Java
- Format date to display month names with the entire date in MySQL?
- Aggregation: group date in nested documents (nested object) and display the count?
Advertisements