/    Sign up×
Community /Pin to ProfileBookmark

Comparing Dates

hi,

i am having a form which consists of 2 textfields which represents 2 dates( from_date && to_date ) , and beside each of them i had placed a calender which will give them dates in the format of YYYY-MM-DD.

i want to compare these date values ie from_date < to_date . FROM_DATE should be LESS than TO_DATE.

how to do this???

thankyou 4 ur patient reading
-gaurav

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogDec 13.2006 — [code=php]
if(strtotime($from_date) < strtotime($to_date))
{
// OK
}
else
{
// error
}
[/code]
Copy linkTweet thisAlerts:
@gaurav_095authorDec 13.2006 — thanks Nogdog.

what if i have to do this thing in Javascript (i mean when the form is submitted then if the condition fails it should prompt fro alert or smthing like that)???
Copy linkTweet thisAlerts:
@NogDogDec 13.2006 — thanks Nogdog.

what if i have to do this thing in Javascript (i mean when the form is submitted then if the condition fails it should prompt fro alert or smthing like that)???[/QUOTE]

That's probably best addressed in the JavaScript forum here. (And remember that you'll still want to validate on the server side in your PHP script, as not everyone has JS enabled on their browser.)
Copy linkTweet thisAlerts:
@gaurav_095authorDec 14.2006 — ok i will try there.
×

Success!

Help @gaurav_095 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...