TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Compare Dates using Strtotime Function in PHP
Kishan Tanpure
Sep 11
2014
Code
1.9
k
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
// Get the dates
$today = date(
"m/d/Y"
);
$datefrom =
"10/01/2010"
;
$dateto =
"10/12/2010"
;
// Convert dates to strings
$todaystring = strtotime($today);
$datefromstring = strtotime($datefrom);
$datetostring = strtotime($dateto);
// Compare the dates (check if today is between start and end dates)
if
($todaystring >= $datefromstring && $todaystring <= $datetostring)
{
// Do something if today is in between
echo
"Date is ok."
;
}
else
{
// Do something if it is not in between
echo
"Date is wrong."
;
}
date
php
strtotime