nasıl iki tarih karşılaştırmak için [yinelenen]

2 Cevap php

Bu soru burada zaten bir cevabı var:

2 Cevap

Bunu yapabilirdi:

$posted_date= $row_Recordset1['date_posted'];
$exp_date= $row_Recordset1['expire_date'];      

if (strtotime($posted_date) >= strtotime($exp_date)) {
    // Do whatever
}

Bu DB tarihleri ​​standart format tarih dizeleri olduğunu varsayarak işe.

Sen Unix timestamps $dt=new DateTime($row_Recordset1['expire_date']); strtotime , assuming they start out as a string, and then they'll just be integers, which you can compare. Another option would be to use DateTime objects, which can be compared using comparison operators. If your date is represented as a format strtotime, yapabileceğiniz anlayan kullanarak bunları açabilirsiniz