how can I convert a date string in the format "1969-03-07T05:00:00.000Z" to the output normally provided by new Date()

yavg

I am using mongodb to save my dates, and I do it by doing new Date()

how can I convert my date to string to the output of new Date()?

let date="1969-03-07T05:00:00.000Z";
let new_date=new Date(date); //in my code it returns "Invalid date"
console.log(new_date);
console.log(new Date());

DadiBit

You might use Date.parse() like:

let date = "1969-03-07T05:00:00.000Z";
let new_date = new Date(Date.parse(date));
console.log(new_date);
console.log(new Date());

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I parse a date (provided as a string) in the "ddMM" format and convert it to a Date Object in Java?

How can I convert to date format (DD MMM YYYY) in file without writing to new file the output

How can I convert a custom `dayHour` string variable to date format?

How can I convert a specific string format to date or datetime in Spark?

How can I convert a date format to another date format in Swift?

How can I convert my date to the appropriate format for doing a new Date()?

How can I convert a date format in SQL?

How do I convert JSON string date to a custom format date?

How do I convert my date string to a custom date format?

How can I convert "/Date(1399739515000)/" into date format in JavaScript?

How can I convert sperated date string to consecutive date string

Android, How can I Convert String to Date?

How can I convert date to string in python?

How can I convert string date to NSDate?

How can I convert a string into a date?

How can I convert string date to NSDate?

How can I convert Date JsonObject to String?

How can I convert date time format string used by C# to the format used by moment.js?

How can I convert this date-format in a format accepted by lubridate?

How do I convert String date to Date format date in dd-MM-yyyy format in java

How can I convert a specific string date to date or datetime in Spark?

How to convert the string to an new Date

How can I format a string into a date: time format?

how do i convert data table date to a certain string format

How do I take string date input and convert it into another format?

How can I convert a date into another format with moment.js?

How can I convert get date to format of yyyymmdd?

How can I convert the Date format for column in sqlite table?

How can I convert this query result to date format (SQL Server)

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    pump.io port in URL

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    flutter: dropdown item programmatically unselect problem

  14. 14

    How to use merge windows unallocated space into Ubuntu using GParted?

  15. 15

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  16. 16

    Nuget add packages gives access denied errors

  17. 17

    Svchost high CPU from Microsoft.BingWeather app errors

  18. 18

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  19. 19

    12.04.3--- Dconf Editor won't show com>canonical>unity option

  20. 20

    Any way to remove trailing whitespace *FOR EDITED* lines in Eclipse [for Java]?

  21. 21

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

HotTag

Archive