(defparameter d
(multiple-value-bind (seconds minutes hours day month year day-of-the-week daylight-savings-time-p time-zone)
(get-decoded-time)
(declare (ignorable day-of-the-week daylight-savings-time-p time-zone))
(format nil "~D-~2,'0D-~2,'0D ~2,'0D:~2,'0D:~2,'0D~%" year month day hours minutes seconds))
"The current date and time as a string value.")
GET-DECODED-TIME returns 9 values. We capture them all in MULTIPLE-VALUE-BIND. I chose to ignore day-of-the-week , daylight-savings-time-p , and time-zone , but they are still bound.
Note that Lisp's FORMAT specifier string is very different from most other languages!
Note that Lisp's FORMAT specifier string is very different from most other languages!
use Time::Piece;
$d = localtime; # local time as a Time::Piece object
say $d->ymd; # yyyy-mm-dd format
say $d->datetime; # ISO 8601 format
$g = gmtime; # GMT as a Time::Piece object
Importing CPAN module Time::Piece replaces perl builtin functions localtime and gmtime with object-oriented equivalents.