Skip to content
Chris Petersen edited this page Oct 16, 2014 · 1 revision

string->seconds converts a string with the given format into seconds.

Parameter Description
str String to be converted
fmt Time format string. Accepting printf % notation and SRFI-19 ~ notation
tz0 Optional: Specification of the timezone

Example

Example 1: Convert some strings to Unix epoch values

> (string->seconds "1990-01-01 0:00:00" "%Y-%m-%d %H:%M:%S")
631177225.
> (string->seconds "2001-09-09 01:46:40" "%Y-%m-%d %H:%M:%S" 0) ;; 1000000000
1000000032.
> (string->seconds "2009-02-13 23:31:30" "%Y-%m-%d %H:%M:%S" 0) ;; 1234567890
1234567924.
Clone this wiki locally