What's the most efficient way to get the current date in ISO format (e.g. "2010-10-06") using Perl?
localtime() function in Perl returns the current date and time of the system, if called without passing any argument.
Use the Date. toISOString() Method to Get Current Date in JavaScript. This method is used to return the date and time in ISO 8601 format. It usually returns the output in 24 characters long format such as YYYY-MM-DDTHH:mm:ss.
You can use the POSIX function strftime() to format date and time with the help of the following table.
Most efficient for you or the computer?
For you:
use POSIX qw/strftime/;
print strftime("%Y-%m-%d", localtime), "\n";
For the Computer:
my @t = localtime;
$t[5] += 1900;
$t[4]++;
printf "%04d-%02d-%02d", @t[5,4,3];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With