- // 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.";
- }
Thursday, 11 September 2014
Compare Dates using Strtotime Function in PHP
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment