Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for sortdate2.pl

(view source code of sortdate2.pl as plain text)

  1. #! perl
  2.  
  3. # SortDate.pl,  Version 2.00
  4. # Display "sorted" date (YYYYMMDD)
  5. # Written by Rob van der Woude
  6. # http://www.robvanderwoude.com
  7.  
  8. # Parse time string
  9. ($day,$month,$year) = (localtime)[3,4,5];
  10.  
  11. # Add "base year"
  12. $year  = $year  + 1900;
  13.  
  14. # Add 1, since month is zero based
  15. $month = $month + 1;
  16.  
  17. # Display result, correctly formated
  18. printf("\nSortDate = %04d%02d%02d\n", $year, $month, $day);
  19.  

page last modified: 2024-02-26; loaded in 0.0243 seconds