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 - Mozilla
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 ...
Discussions

how to convert a string to a Unix timestamp in javascript? - Stack Overflow
I want to convert a string "2013-09-05 15:34:00" into a Unix timestamp in javascript. Can any one tell how to do that? thanks. More on stackoverflow.com
🌐 stackoverflow.com
date - Convert a Unix timestamp to time in JavaScript - Stack Overflow
I am storing time in a MySQL database ... sent to some JavaScript code. How would I get just the time out of it? For example, in HH/MM/SS format. ... Just multiply by 1000 since JS timestamps are in milliseconds and PHP delivers in seconds. ... Here is a very useful link with different date format: timestamp.online/article/… Combine with the multiplication by 1000 and it gets the job done! ... If you have a string in a different ... More on stackoverflow.com
🌐 stackoverflow.com
date - Javascript Converting human time to timestamp - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... Using javascript, How can I convert a "human time" string like "Wed Jun 20 19:20:44 +0000 2012" into a timestamp value like "1338821992"? More on stackoverflow.com
🌐 stackoverflow.com
javascript - How to convert date to timestamp? - Stack Overflow
The first code example is still wrong, and using Number on strings starting with a 0 is problematic on some engines -- use parseInt and specify a radix. 2012-03-26T14:09:30.747Z+00:00 ... To convert (ISO) date to Unix timestamp, I ended up with a timestamp 3 characters longer than needed so ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
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); // ...
Find elsewhere
🌐
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.
🌐
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 Web Docs
July 10, 2025 - 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).
🌐
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.
🌐
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
February 19, 2023 - 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));
🌐
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
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date
Date - JavaScript | MDN - Mozilla
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).
🌐
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).
🌐
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"
🌐
Toptal
toptal.com › software › definitive-guide-to-datetime-manipulation
How to get the Timestamp And Date in Javascript: JS DateTime | Toptal®
December 2, 2020 - This makes JavaScript date-from-timestamp and JavaScript timestamp-to-date conversion straightforward, provided the UTC time zone is used. If you don’t intend to support <IE8, you can use Date.now() to directly get the time stamp without having to create a new Date object. Converting a string to ...