Print current date and time as an epoch and in a human-readable format.
In Perl 6, the
time function returns the current time as the Unix epoch:
The output is something like this:
For manipulating dates and times, use the built-in
The date is now in a more human-readable format, although still is overloaded with many details:
To access the separate elements of date and time, use the methods on the variable of the
my $dt = DateTime.now;
say $dt.day; # 26
say $dt.month; # 5
say $dt.year; # 2017
say $dt.hour; # 10
say $dt.minute; # 9
say $dt.second; # 5.55802702903748
The meaning of all the elements is quite straightforward.
All the values except seconds are integer. For the seconds, you may want to take the integer part only: