Last active
June 14, 2019 13:47
-
-
Save roneygomes/66bdeadf684a507f1b345c21e48452f0 to your computer and use it in GitHub Desktop.
Convert ISO date string to milliseconds since epoch.
This file contains 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
(defn date-str->millis [date-str] | |
(let [milliseconds-in-a-day (* 24 60 60 1000)] | |
(-> (LocalDate/parse date-str DateTimeFormatter/ISO_DATE) | |
(.toEpochDay) | |
(* milliseconds-in-a-day)))) | |
;; Examples: | |
;; (date-str->millis "2014-12-01") | |
;; => 1417392000000 | |
;; (date-str->millis "2020-08-15") | |
;; => 1597449600000 | |
;; (date-str->millis "2019-02-27") | |
;; => 1551225600000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment