Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Compare Dates using Strtotime Function in PHP
WhatsApp
Kishan Tanpure
Sep 11
2014
2.1
k
0
1
// 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."
;
}
strtotime
php
date
Up Next
Compare Dates using Strtotime Function in PHP