Last active
August 29, 2015 14:07
-
-
Save supasympa/e76a20c334caa4a9d8cf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * gets the number of milliseconds from a date using a date format. | |
| * @param dateString : the date to convert | |
| * @param format : the format the date is in | |
| * @returns Milliseconds from 01/01/1970 | |
| */ | |
| return function (dateString, format){ | |
| function getDatePart(part){ | |
| var re, start, end; | |
| re = new RegExp(part); | |
| start = re.exec(format).index; | |
| end = start + part.length; | |
| return dateString.substring(start, end) | |
| }; | |
| return (new Date(+getDatePart('yyyy'), +getDatePart('mm'), +getDatePart('dd'))).valueOf(); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment