পিএইচপি-তে দুটি তারিখের তুলনা করতে, কোডটি নিম্নরূপ। এখানে, আমরা তারিখগুলি −
তুলনা করতে সমতা অপারেটর ব্যবহার করেছিউদাহরণ
<?php $dateOne = "2019-10-30"; $dateTwo = "2019-10-30"; echo "Date1 = $dateOne"; echo "\nDate2 = $dateTwo"; if ($dateOne == $dateTwo) echo "\nBoth the dates are equal!"; else echo "Both the dates are different!"; ?>
আউটপুট
এটি নিম্নলিখিত আউটপুট-
তৈরি করবেDate1 = 2019-10-30 Date2 = 2019-10-30 Both the dates are equal!
উদাহরণ
আসুন এখন আরেকটি উদাহরণ দেখি---
<?php $dateOne = "2019-11-08"; $dateTwo = "2018-08-10"; echo "Date1 = $dateOne"; echo "\nDate2 = $dateTwo"; if ($dateOne < $dateTwo) echo "\nDateTwo is the latest date!"; else echo "\nDateOne is the latest date!"; ?>
আউটপুট
এটি নিম্নলিখিত আউটপুট-
তৈরি করবেDate1 = 2019-11-08 Date2 = 2018-08-10 DateOne is the latest date!