Check out example codes for "perl sprintf YYYYMMDD sample". It will help you in understanding the concepts better.

Code Example 1

my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
my $now = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $year+1900, $mon+1, $mday, $hour, $min, $sec);

Learn ReactJs, React Native from akashmittal.com