Parsing dates is a pain in JavaScript as there's no extensive native support. However you could do something like the following by relying on the Date(year, month, day [, hour, minute, second, millisecond]) constructor signature of the Date object.

var dateString = '17-09-2013 10:08',
    dateTimeParts = dateString.split(' '),
    timeParts = dateTimeParts[1].split(':'),
    dateParts = dateTimeParts[0].split('-'),
    date;

date = new Date(dateParts[2], parseInt(dateParts[1], 10) - 1, dateParts[0], timeParts[0], timeParts[1]);

console.log(date.getTime()); //1379426880000
console.log(date); //Tue Sep 17 2013 10:08:00 GMT-0400

You could also use a regular expression with capturing groups to parse the date string in one line.

var dateParts = '17-09-2013 10:08'.match(/(\d+)-(\d+)-(\d+) (\d+):(\d+)/);

console.log(dateParts); // ["17-09-2013 10:08", "17", "09", "2013", "10", "08"]
Answer from plalx on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › parse
Date.parse() - JavaScript | MDN
The Date.parse() static method parses a string representation of a date, and returns the date's timestamp. // Standard date-time string format const unixTimeZero = Date.parse("1970-01-01T00:00:00Z"); // Non-standard format resembling toUTCString() const javaScriptRelease = Date.parse("04 Dec ...
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-convert-a-date-string-to-timestamp-in-javascript
How to Convert a Date String to Timestamp in JavaScript ? - GeeksforGeeks
July 23, 2025 - ... Example: In this example, we are using the above-explained method. ... In this approach, using new Date() creates a date object from a string, then .getTime() extracts the Unix timestamp (milliseconds since 1970).
🌐
Stack Abuse
stackabuse.com › bytes › how-to-convert-a-date-to-timestamp-in-javascript
How to Convert a Date to Timestamp in JavaScript
October 4, 2023 - It'll be a similar process as before, but with the extra step of converting the string to a Date object and then the timestamp. Just make sure your date string is in a format that the Date constructor can understand. According to MDN: The JavaScript specification only specifies one format to ...
🌐
Bobby Hadz
bobbyhadz.com › blog › javascript-convert-date-to-timestamp
Convert a Date or Date String to Timestamp in JavaScript | bobbyhadz
The getTime() method returns the number of milliseconds since the Unix Epoch (1st of January, 1970 00:00:00). If you need to convert the result to seconds, divide it by 1000. ... Copied!const str = '2022-04-26'; const date = new Date(str); // ...
🌐
Plain English
plainenglish.io › home › blog › javascript › how to convert a date string to timestamp in javascript?
How to Convert a Date String to Timestamp in JavaScript?
April 19, 2022 - In this article, we'll look at ways to convert a date to a timestamp in JavaScript. We can use the Date.parse() method to convert the date string into a timestamp.
Find elsewhere
🌐
Index.dev
index.dev › blog › convert-string-to-date-javascript
6 Easy Ways To Convert String to Date in JavaScript
This blog post outlines six straightforward methods for converting a string to a date in JavaScript. Every approach possesses distinct advantages and applications: Date Constructor: Efficient and direct for ISO format. Date.parse(): Suitable for timestamps including temporal data.
🌐
JavaScript in Plain English
javascript.plainenglish.io › how-to-convert-a-date-string-to-timestamp-in-javascript-2593abcaca5a
How to Convert a Date String to Timestamp in JavaScript? | JavaScript in Plain English
April 20, 2022 - We can use the getTime() method of a Date instance to convert the date string into a timestamp. ... const toTimestamp = (strDate) => { const dt = new Date(strDate).getTime(); return dt / 1000; } console.log(toTimestamp('02/13/2020 23:31:30')); ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › toTimeString
Date.prototype.toTimeString() - JavaScript | MDN
const event = new Date("August 19, 1975 23:15:30"); console.log(event.toTimeString()); // Expected output: "23:15:30 GMT+0200 (CEST)" // Note: your timezone may vary ... A string representing the time portion of the given date (see description for the format).
🌐
Sling Academy
slingacademy.com › article › javascript-convert-timestamp-to-date-time-and-vice-versa
JavaScript: Convert timestamp to date time and vice versa - Sling Academy
It is used to represent the date, time, and time zone of a particular moment of life. The main difference between Unix timestamp and date time is the way in which they are represented. Unix timestamp is represented as a · numeric value, whereas date time is represented as a ... // define a reusable function const timestampToDate = (timestamp) => { var date = new Date(timestamp * 1000); return date.toLocaleDateString('en-US', { weekday: 'long', year: 'numeric', month: 'short', day: 'numeric', }); }; // try it console.log(timestampToDate(1479693087)); console.log(timestampToDate(1450138800));
🌐
Codedamn
codedamn.com › news › javascript
How to convert timestamp to date in JavaScript?
November 3, 2022 - In JavaScript, we can use this library to convert and format the timestamp value into a valid date format. We will utilize the moment.unix() method to do this.
🌐
InfluxData
influxdata.com › home › how to get, convert & format javascript date from timestamp | influxdata
How to Get, Convert & Format JavaScript Date From Timestamp | InfluxData
February 10, 2023 - In addition to formatting dates for multiple regions and time zones, Moment.js can perform complex operations such as computing differences between dates, parsing dates from strings, and manipulating dates with different calendar systems. To use Moment.js, we first need to install it via a package manager such as npm or yarn. Once installed, we can use its API to format dates in various ways. const moment = require('moment'); const timestamp = 1616608200000; // example timestamp const formattedDate = moment(timestamp).format('dddd, MMMM Do YYYY'); console.log(formattedDate); // prints "Wednesday, March 24th 2021"
🌐
W3Schools
w3schools.com › jsref › jsref_tostring_date.asp
JavaScript Date toString() Method
altKey (Mouse) altKey (Key) animationName bubbles button buttons cancelable charCode clientX clientY code ctrlKey (Mouse) ctrlKey (Key) currentTarget data defaultPrevented deltaX deltaY deltaZ deltaMode detail elapsedTime elapsedTime eventPhase inputType isTrusted key keyCode location metaKey (Mouse) metaKey (Key) newURL oldURL offsetX offsetY pageX pageY persisted propertyName relatedTarget relatedTarget screenX screenY shiftKey (Mouse) shiftKey (Key) target targetTouches timeStamp touches type which (Mouse) which (Key) view HTML Event Methods
🌐
JavaScript.info
javascript.info › tutorial › the javascript language › data types
Date and time
The call to Date.parse(str) parses the string in the given format and returns the timestamp (number of milliseconds from 1 Jan 1970 UTC+0).
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date
Date - JavaScript | MDN
Note: While the time value at the heart of a Date object is UTC, the basic methods to fetch the date and time or its components all work in the local (i.e., host system) time zone and offset. The maximum timestamp representable by a Date object is slightly smaller than the maximum safe integer (Number.MAX_SAFE_INTEGER, which is 9,007,199,254,740,991).
🌐
Timestamp Converter
timestamp.online › article › how-to-convert-timestamp-to-datetime-in-javascript
How To Convert Timestamp To Date and Time in JavaScript - Code Example
Converts a Date object to a string, according to universal time · You can learn more about toDateString in documentation. var ts = new Date(1768200518000); console.log(ts.toDateString()); # Mon Jan 12 2026 · You can learn more about toISOString in documentation. var ts = new Date(1768200518 * 1000); console.log(ts.toISOString()); # 26-01-12T07:48:38+01:00 · var ts = new Date(1768200518000); JavaScript ·