Skip to content

Instantly share code, notes, and snippets.

@kell05
Created November 23, 2011 11:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kell05/1388468 to your computer and use it in GitHub Desktop.
Save kell05/1388468 to your computer and use it in GitHub Desktop.
Returns the current date in yyyymmdd format
sub current_date{
my ($d,$m,$y) = (localtime)[3,4,5];
# Normalise dates
($m+=1,$y+=1900);
# Check prefix with zero
$m = "0$m" if ($m < 10);
$d = "0$d" if ($d < 10);
return "$y$m$d";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment