# Function Name : getDateTime
# Input : Time in epoch or it could be empty. In latter case, it would return current date and time.
# Output : current time in dd-mm-yyyy hh:mm:sec format.
# Description : This function returns current date and time in above given format.
# Created By : Rinkesh Bansal
# Date : 25-Sep-2011
#
sub getDateTime($)
{
my ($input) = @_;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst);
if (trim($input) eq "")
{
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
}
else
{
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($input);
}
$mon = $mon+1;
$year = $year + 1900;
$mday = (length($mday) eq 1)?0 . $mday:$mday;
$mon = (length($mon) eq 1)?0 . $mon:$mon;
$hour = (length($hour) eq 1)?0 . $hour:$hour;
$min = (length($min) eq 1)?0 . $min:$min;
$sec = (length($sec) eq 1)?0 . $sec:$sec;
return "$mday-$mon-$year $hour:$min:$sec"; // change this line to change the format you like it to return
}
# Input : Time in epoch or it could be empty. In latter case, it would return current date and time.
# Output : current time in dd-mm-yyyy hh:mm:sec format.
# Description : This function returns current date and time in above given format.
# Created By : Rinkesh Bansal
# Date : 25-Sep-2011
#
sub getDateTime($)
{
my ($input) = @_;
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst);
if (trim($input) eq "")
{
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
}
else
{
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($input);
}
$mon = $mon+1;
$year = $year + 1900;
$mday = (length($mday) eq 1)?0 . $mday:$mday;
$mon = (length($mon) eq 1)?0 . $mon:$mon;
$hour = (length($hour) eq 1)?0 . $hour:$hour;
$min = (length($min) eq 1)?0 . $min:$min;
$sec = (length($sec) eq 1)?0 . $sec:$sec;
return "$mday-$mon-$year $hour:$min:$sec"; // change this line to change the format you like it to return
}