JanetDocsPlaygroundI'm feeling luckyGitHub sign in

os/mktime



    cfunction
    src/core/os.c on line 1428, column 1

    (os/mktime date-struct &opt local)

    Get the broken down date-struct time expressed as the number of 
    seconds since January 1, 1970, the Unix epoch. Returns a real 
    number. Date is given in UTC unless `local` is truthy, in which 
    case the date is computed for the local timezone.

    Inverse function to os/date.


2 examplesSign in to add an example
Loading...
(defn parse-date
  "Parses YYYY-MM-DD date format to time"
  [date]
  (let [[year month day] (map scan-number (string/split "-" date))]
    (os/mktime {:year year :month month :day day})))

(print (parse-date "2021-01-01")) # 1612137600
aquilaxPlayground
(os/time)  # => 1593838384
(os/date)  # => {:month 6 :dst false :year-day 185 :seconds 8 :minutes 53 :week-day 6 :year 2020 :hours 4 :month-day 3}
(os/mktime (os/date))  # => 1593838390
cellularmitosisPlayground