close

How to convert dd/mm/yyyy string into JavaScript Date object?

Hello Guys, How are you all? Hope You all Are Fine. Today we are going to learn How to convert dd/mm/yyyy string into JavaScript Date object? in javascript. So Here I am Explain to you all the possible methods here.

Without wasting your time, Let’s start This Article.

How to convert dd/mm/yyyy string into JavaScript Date object ?

  1. How to convert dd/mm/yyyy string into JavaScript Date object ?

    convert dd/mm/yyyy string into JavaScript Date object var date = new Date("enter your date");//2018-01-17 14:58:29.013
    Just one line is enough no need to do any kind of splitjoin, etc.:
    $scope.ssdate=date.toLocaleDateString();// mm/dd/yyyy format

  2. convert dd/mm/yyyy string into JavaScript Date object

    convert dd/mm/yyyy string into JavaScript Date object var date = new Date("enter your date");//2018-01-17 14:58:29.013
    Just one line is enough no need to do any kind of splitjoin, etc.:
    $scope.ssdate=date.toLocaleDateString();// mm/dd/yyyy format

Method 1

var dateString = "23/10/2015"; // Oct 23
var newData = dateString.replace(/(\d+[/])(\d+[/])/, '$2$1');
var data = new Date(newData);

document.body.innerHTML = date.toString();ere

Method 2

var date = new Date("enter your  date");//2018-01-17 14:58:29.013

Just one line is enough no need to do any kind of splitjoin, etc.:

$scope.ssdate=date.toLocaleDateString();//  mm/dd/yyyy format

Summery

It’s all About this article. Hope all method helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which method worked for you? Thank You.

Leave a Comment