open Unix (* Convert Date to Unix timestamp *) let tm = { tm_sec = 45; tm_min = 30; tm_hour = 8; tm_mday = 15; tm_mon = 4; (* May is the 5th month, but zero-based, so 4 *) tm_year = 120; (* 2020 - 1900 *) tm_wday = 0; (* Ignored by mktime *) tm_yday = 0; (* Ignored by mktime *) tm_isdst = false; (* Not using daylight saving time *) } let (unix_timestamp, _) = Unix.mktime tm let () = Printf.printf "Unix Timestamp: %.0f\n" unix_timestamp
tm
Unix.mktime
Printf.printf
tm_mon
tm_year
Unix.time()
Unix.gmtime()
Unix.gmtime(1589530245.0)
Unix.localtime()
Unix.localtime(1589530245.0)
Unix.mktime()
Unix.mktime(tm)
Unix.strftime()
Unix.strftime "%Y-%m-%d" tm
Unix.strptime()
Unix.strptime "%Y-%m-%d" "2020-05-15"
Unix.sleep()
Unix.sleep(5)
Unix.gettimeofday()