Formatting current system date in Common Lisp

Viewed 1812

I am trying to get the current system date in Common Lisp through following function

(defun current-date-string ()
  "Returns current date as a string."
  (multiple-value-bind (sec min hr day mon yr dow dst-p tz)
                       (get-decoded-time)
    (declare (ignore sec min hr dow dst-p tz))
    (format nil "~A-~A-~A" yr mon day)))

Unfortunately I am getting the current date in this format "2014-1-2". However actually I need this format "2014-01-02". Is any way we can change the format? I tried replacing nil with yyyy-mm-dd but no luck. However my machine clock shows the date format is "2014-01-02".

2 Answers
Related