Perl date matching

I want to combine the date in the format day / month / year. where day is two digits, month is two digits, and year is four digits. In addition, I want to check whether this is a valid date, for example, knows when a leap year is, and I know which month has 30 days, 31 days and 28 or 29 days for Februaryrari.

+2
source share
2 answers

Look at something like Date :: Manip ; there’s little point in doing it yourself when such things are available.

$date = ParseDate($mydate); unless ($date) { # error } ... 
+4
source

use the following code

 use strict; use warnings; use Date::Manip; my $start="2010:03:30:23:02:3"; my $split=":"; my($year,$month,$date,$hour,$min,$sec); ($year,$month,$date,$hour,$min,$sec)=split($split,$start); my $result = ParseDate("$month/$date/$year"); if(!$result) { print "Invalid Date\n"; exit; } 
+1
source

All Articles