js get time format from string 01:49:09 code example

Example 1: parse date from string in js

Date.parse(dateString)
//dateString is like 2020-10-10 / 2020-10-10T10:20:20

Example 2: javascript full date as string

<p>The toDateString() method converts a date to a date string:</p>

<p id="demo"></p>

<script>
var d = new Date();
document.getElementById("demo").innerHTML = d.toDateString();
</script>
//output: Fri Oct 16 2020

Example 3: javascript date format

Modern JavaScript date utility library https://date-fns.org/
date-fns provides the most comprehensive, yet simple and consistent toolset for manipulating JavaScript dates in a browser & Node.js.