Gossamer Forum
Home : Products : DBMan : Installation :

Change Date format into european format

Quote Reply
Change Date format into european format
I am using DBman for european surfers. I put a date in my database to be filled in by the user.
The format in Europe should be DD/MM/YY or DD/MM/YYYY like today 20/06/99.
How can I change this and where? The default value &get_date does not work either, certainly for the same reason.
Could someone help me?
Thanks a lot
Quote Reply
Re: Change Date format into european format In reply to
With the Y2K thing coming up, it would probably be best to use DD/MM/YYYY.

You'll need to change both sub get_date and sub date_to_unix.

Code:
sub get_date {
# --------------------------------------------------------
$time = @_[0];
($time) or ($time = time());

my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime($time);
++$mon;
($mon < 10) and ($mon = "0$mon");
($day < 10) and ($day = "0$day");
$year = $year + 1900;

return "$day/$mon/$year";
}

Code:
sub date_to_unix {
# --------------------------------------------------------

my ($date) = $_[0];
my ($time);
my ($day, $mon, $year) = split(/\//, $_[0]);
unless ($day and $mon and $year) { return undef; }
use Time::Local;
eval {
$day = int($day); $year = int($year) - 1900; $mon = int($mon) - 1;
$time = timelocal(0,0,0,$day,$mon,$year);
};
if ($@) { return undef; } # Could return 0 if you want.
return ($time);
}

I have tested this and it works. Smile

------------------
JPD





Quote Reply
Re: Change Date format into european format In reply to
Hiya Carol!

Quote:
I have tested this and it works.

Jeez, I thought you would know better by now than to make sweeping statements like that!

Just kidding! Smile

adam
Quote Reply
Re: Change Date format into european format In reply to
JPDeni,

Does this mod also work with the What's New mod and the archive mod that you gave me (looks for all records older than 'x' days and moves to another database)?
Quote Reply
Re: Change Date format into european format In reply to
I have no idea. I've had so many variations of the "What's New" mod that I don't know which one I gave to whom. I'd have to see it to be able to tell you.


------------------
JPD