Comparing dates in Perl

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
php_ghost
Forum Commoner
Posts: 55
Joined: Thu Jan 11, 2007 3:29 am

Comparing dates in Perl

Post by php_ghost »

Here's the scenario.

I have in my database,a field called "inserted" which is a datetime. Now I have a variable in my Perl script that contains another datetime value. I want to compare these two dates to find out which one is more recent.
However I have no clue on how to do this. Please help me guys. :cry: :cry:

TIA
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Ask the database to return the results where the datetime field has been altered to the format Perl is using. It's been too long for me to remember such details, unfortunately.

Preferably you can get them in YYYY-MM-DD HH:MM:SS format as these sort themselves naturally when compared.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

(#10850)
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

There are 10 types of people in this world, those who understand binary and those who don't
php_ghost
Forum Commoner
Posts: 55
Joined: Thu Jan 11, 2007 3:29 am

Post by php_ghost »

Hi i've tried using timelocal in my localhost and it worked fine. I was able to convert both dates to seconds so i was able to know which was more recent. However when i uploaded the script to the server I got this error:

Undefined subroutine &main::timelocal. Please help me fix this :cry: :cry:

TIA
Post Reply