Hướng dẫn how do you check if a date is greater than today in php? - làm thế nào để bạn kiểm tra xem một ngày có lớn hơn ngày hôm nay trong php?

Vui lòng giúp đỡ những gì sai với mã của tôi? Nó luôn luôn trả về ngày hôm nay lớn hơn '01/02/2016 'trong đó năm 2016 lớn hơn năm 2015.

<?php
$date_now = date("m/d/Y");

$date = date_create("01/02/2016");
$date_convert = date_format($date, "m/d/Y");

if ($date_now > $date_convert) {
    echo 'greater than';
} else {
    echo 'Less than';
}

P.S: 01/02/2016 đến từ cơ sở dữ liệu.

Hướng dẫn how do you check if a date is greater than today in php? - làm thế nào để bạn kiểm tra xem một ngày có lớn hơn ngày hôm nay trong php?

Đã hỏi ngày 18 tháng 9 năm 2015 lúc 1:20Sep 18, 2015 at 1:20

Hướng dẫn how do you check if a date is greater than today in php? - làm thế nào để bạn kiểm tra xem một ngày có lớn hơn ngày hôm nay trong php?

1

Bạn không so sánh ngày. Bạn đang so sánh các chuỗi. Trong thế giới so sánh chuỗi, 09/17/2015> 01/02/2016

<?php
 $date_now = date("Y-m-d"); // this format is string comparable

if ($date_now > '2016-01-02') {
    echo 'greater than';
}else{
    echo 'Less than';
}
0>
<?php
 $date_now = date("Y-m-d"); // this format is string comparable

if ($date_now > '2016-01-02') {
    echo 'greater than';
}else{
    echo 'Less than';
}
1. Bạn cần đặt ngày của mình ở định dạng chuỗi có thể so sánh hoặc so sánh các đối tượng
<?php
 $date_now = date("Y-m-d"); // this format is string comparable

if ($date_now > '2016-01-02') {
    echo 'greater than';
}else{
    echo 'Less than';
}
2 có thể so sánh.

<?php
 $date_now = date("Y-m-d"); // this format is string comparable

if ($date_now > '2016-01-02') {
    echo 'greater than';
}else{
    echo 'Less than';
}

Thử nghiệm

Hoặc

<?php
 $date_now = new DateTime();
 $date2    = new DateTime("01/02/2016");

if ($date_now > $date2) {
    echo 'greater than';
}else{
    echo 'Less than';
}

Thử nghiệm

HoặcSep 18, 2015 at 1:24

Đã trả lời ngày 18 tháng 9 năm 2015 lúc 1:24John Conde

John Condejohn Conde98 gold badges447 silver badges490 bronze badges

7

215K98 Huy hiệu vàng447 Huy hiệu bạc490 Huy hiệu Đồng

<?php

    $date_now = time(); //current timestamp
    $date_convert = strtotime('2022-08-01');

    if ($date_now > $date_convert) {
        echo 'greater than';
    } else {
        echo 'Less than';
    }

?>

Chúng ta có thể chuyển đổi ngày thành dấu thời gian để so sánhJul 21, 2021 at 5:29

Đã trả lời ngày 21 tháng 7 năm 2021 lúc 5:29Joyal

Niềm vui3 gold badges29 silver badges42 bronze badges

2.5073 huy hiệu vàng29 Huy hiệu bạc42 Huy hiệu đồng

<?php
 $today = date("Y-m-d"); //Today
 $date = '2022-06-30'; //Date

 if (strtotime($today) > strtotime($date)) {
    echo 'Today is greater than date';
 }else{
    echo 'Today is less than date';
}

Các ngày có thể ở các định dạng khác nhau, vì vậy tốt hơn là chuyển đổi chúng thành dấu thời gian trước khi so sánhJun 30 at 8:26

Hướng dẫn how do you check if a date is greater than today in php? - làm thế nào để bạn kiểm tra xem một ngày có lớn hơn ngày hôm nay trong php?

1

Xem thảo luận

Cải thiện bài viết

Lưu bài viết

  • Đọc
  • Bàn luận
  • Xem thảo luận

    Cải thiện bài viết

    Lưu bài viết

    Đọc

    Bàn luận If the given dates are in the same format then use a simple comparison operator to compare the dates.

    Example:

    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    3

    Cho hai ngày (ngày 1 và ngày 2) và nhiệm vụ là so sánh các ngày đã cho. So sánh hai ngày trong PHP rất đơn giản khi cả hai ngày ở cùng định dạng nhưng vấn đề phát sinh khi cả hai ngày ở một định dạng khác nhau.

    Phương pháp 1: Nếu các ngày đã cho ở cùng định dạng thì sử dụng toán tử so sánh đơn giản để so sánh các ngày.

    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    4
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    5
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    6
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    7

    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    8
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    5
    <?php
     $date_now = new DateTime();
     $date2    = new DateTime("01/02/2016");
    
    if ($date_now > $date2) {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    0
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    7

    <?php
    
        $date_now = time(); //current timestamp
        $date_convert = strtotime('2022-08-01');
    
        if ($date_now > $date_convert) {
            echo 'greater than';
        } else {
            echo 'Less than';
        }
    
    ?>
    
    2

    <?php
     $date_now = new DateTime();
     $date2    = new DateTime("01/02/2016");
    
    if ($date_now > $date2) {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    2
    <?php
     $date_now = new DateTime();
     $date2    = new DateTime("01/02/2016");
    
    if ($date_now > $date2) {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    3
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    4
    <?php
     $date_now = new DateTime();
     $date2    = new DateTime("01/02/2016");
    
    if ($date_now > $date2) {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    5
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    8
    <?php
     $date_now = new DateTime();
     $date2    = new DateTime("01/02/2016");
    
    if ($date_now > $date2) {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    7

    <?php
    
        $date_now = time(); //current timestamp
        $date_convert = strtotime('2022-08-01');
    
        if ($date_now > $date_convert) {
            echo 'greater than';
        } else {
            echo 'Less than';
        }
    
    ?>
    
    7

    Output:

    1998-11-24 is latest than 1997-03-26
    

    <?php
     $date_now = new DateTime();
     $date2    = new DateTime("01/02/2016");
    
    if ($date_now > $date2) {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    8
    <?php
     $date_now = new DateTime();
     $date2    = new DateTime("01/02/2016");
    
    if ($date_now > $date2) {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    9
    <?php
    
        $date_now = time(); //current timestamp
        $date_convert = strtotime('2022-08-01');
    
        if ($date_now > $date_convert) {
            echo 'greater than';
        } else {
            echo 'Less than';
        }
    
    ?>
    
    0
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    7
    If both of the given dates are in different formats then use strtotime() function to convert the given dates into the corresponding timestamp format and lastly compare these numerical timestamps to get the desired result.

    Example:

    <?php
     $date_now = new DateTime();
     $date2    = new DateTime("01/02/2016");
    
    if ($date_now > $date2) {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    8
    <?php
     $date_now = new DateTime();
     $date2    = new DateTime("01/02/2016");
    
    if ($date_now > $date2) {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    9
    <?php
    
        $date_now = time(); //current timestamp
        $date_convert = strtotime('2022-08-01');
    
        if ($date_now > $date_convert) {
            echo 'greater than';
        } else {
            echo 'Less than';
        }
    
    ?>
    
    5
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    7

    Phương pháp 2: Nếu cả hai ngày đã cho ở các định dạng khác nhau thì hãy sử dụng hàm strtotime () để chuyển đổi các ngày đã cho thành định dạng dấu thời gian tương ứng và cuối cùng so sánh các dấu thời gian số này để có kết quả mong muốn.

    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    3

    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    4
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    5
    <?php
     $today = date("Y-m-d"); //Today
     $date = '2022-06-30'; //Date
    
     if (strtotime($today) > strtotime($date)) {
        echo 'Today is greater than date';
     }else{
        echo 'Today is less than date';
    }
    
    1
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    7

    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    8
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    5
    <?php
     $today = date("Y-m-d"); //Today
     $date = '2022-06-30'; //Date
    
     if (strtotime($today) > strtotime($date)) {
        echo 'Today is greater than date';
     }else{
        echo 'Today is less than date';
    }
    
    5
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    7

    <?php
     $today = date("Y-m-d"); //Today
     $date = '2022-06-30'; //Date
    
     if (strtotime($today) > strtotime($date)) {
        echo 'Today is greater than date';
     }else{
        echo 'Today is less than date';
    }
    
    7
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    5
    <?php
     $today = date("Y-m-d"); //Today
     $date = '2022-06-30'; //Date
    
     if (strtotime($today) > strtotime($date)) {
        echo 'Today is greater than date';
     }else{
        echo 'Today is less than date';
    }
    
    9
    <?php
     $date_now = new DateTime();
     $date2    = new DateTime("01/02/2016");
    
    if ($date_now > $date2) {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    3
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    4
    1998-11-24 is latest than 1997-03-26
    
    2

    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    8
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    5
    <?php
     $date_now = new DateTime();
     $date2    = new DateTime("01/02/2016");
    
    if ($date_now > $date2) {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    0
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    7

    <?php
    
        $date_now = time(); //current timestamp
        $date_convert = strtotime('2022-08-01');
    
        if ($date_now > $date_convert) {
            echo 'greater than';
        } else {
            echo 'Less than';
        }
    
    ?>
    
    2

    <?php
     $date_now = new DateTime();
     $date2    = new DateTime("01/02/2016");
    
    if ($date_now > $date2) {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    2
    <?php
     $date_now = new DateTime();
     $date2    = new DateTime("01/02/2016");
    
    if ($date_now > $date2) {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    3
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    4
    <?php
     $date_now = new DateTime();
     $date2    = new DateTime("01/02/2016");
    
    if ($date_now > $date2) {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    5
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    8
    <?php
     $date_now = new DateTime();
     $date2    = new DateTime("01/02/2016");
    
    if ($date_now > $date2) {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    7

    <?php
    
        $date_now = time(); //current timestamp
        $date_convert = strtotime('2022-08-01');
    
        if ($date_now > $date_convert) {
            echo 'greater than';
        } else {
            echo 'Less than';
        }
    
    ?>
    
    7

    Output:

    12-03-26 is latest than 2011-10-24
    

    <?php
     $date_now = new DateTime();
     $date2    = new DateTime("01/02/2016");
    
    if ($date_now > $date2) {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    8
    <?php
     $date_now = new DateTime();
     $date2    = new DateTime("01/02/2016");
    
    if ($date_now > $date2) {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    9
    <?php
    
        $date_now = time(); //current timestamp
        $date_convert = strtotime('2022-08-01');
    
        if ($date_now > $date_convert) {
            echo 'greater than';
        } else {
            echo 'Less than';
        }
    
    ?>
    
    0
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    7
    Using DateTime class to compare two dates.

    Example:

    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    3

    <?php
     $date_now = new DateTime();
     $date2    = new DateTime("01/02/2016");
    
    if ($date_now > $date2) {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    8
    <?php
     $date_now = new DateTime();
     $date2    = new DateTime("01/02/2016");
    
    if ($date_now > $date2) {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    9
    <?php
    
        $date_now = time(); //current timestamp
        $date_convert = strtotime('2022-08-01');
    
        if ($date_now > $date_convert) {
            echo 'greater than';
        } else {
            echo 'Less than';
        }
    
    ?>
    
    5
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    7

    Phương pháp 2: Nếu cả hai ngày đã cho ở các định dạng khác nhau thì hãy sử dụng hàm strtotime () để chuyển đổi các ngày đã cho thành định dạng dấu thời gian tương ứng và cuối cùng so sánh các dấu thời gian số này để có kết quả mong muốn.

    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    4
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    5
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    6
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    7

    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    8
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    5
    <?php
     $date_now = new DateTime();
     $date2    = new DateTime("01/02/2016");
    
    if ($date_now > $date2) {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    0
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    7

    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    01
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    02
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    801/02/2016701/02/20168
    1998-11-24 is latest than 1997-03-26
    
    2

    <?php
    
        $date_now = time(); //current timestamp
        $date_convert = strtotime('2022-08-01');
    
        if ($date_now > $date_convert) {
            echo 'greater than';
        } else {
            echo 'Less than';
        }
    
    ?>
    
    2

    <?php
     $date_now = new DateTime();
     $date2    = new DateTime("01/02/2016");
    
    if ($date_now > $date2) {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    2
    <?php
     $date_now = new DateTime();
     $date2    = new DateTime("01/02/2016");
    
    if ($date_now > $date2) {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    3
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    4
    <?php
     $date_now = new DateTime();
     $date2    = new DateTime("01/02/2016");
    
    if ($date_now > $date2) {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    5
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    8
    <?php
     $date_now = new DateTime();
     $date2    = new DateTime("01/02/2016");
    
    if ($date_now > $date2) {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    7

    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    01
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    02
    <?php
     $date_now = date("Y-m-d"); // this format is string comparable
    
    if ($date_now > '2016-01-02') {
        echo 'greater than';
    }else{
        echo 'Less than';
    }
    
    801/02/2016701/02/20168
    1998-11-24 is latest than 1997-03-26
    
    2

    <?php
    
        $date_now = time(); //current timestamp
        $date_convert = strtotime('2022-08-01');
    
        if ($date_now > $date_convert) {
            echo 'greater than';
        } else {
            echo 'Less than';
        }
    
    ?>
    
    7

    Output:

    2012-11-24 is latest than 2011-03-26
    

    PHP là ngôn ngữ kịch bản phía máy chủ được thiết kế dành riêng cho phát triển web. Bạn có thể học PHP từ đầu bằng cách làm theo hướng dẫn PHP và các ví dụ PHP này.


    Làm thế nào tôi có thể so sánh ngày hôm nay với một ngày khác trong PHP?

    Khi bạn đã tạo các đối tượng DateTime của mình, bạn cũng có thể gọi phương thức diff () trên một đối tượng và chuyển nó vào ngày khác để tính toán chênh lệch giữa các ngày. Điều này sẽ cung cấp cho bạn một đối tượng DateInterval. $ last = new DateTime ("25 tháng 12 năm 2020"); $ now = new datetime ("bây giờ");call the diff() method on one object and pass it the other date in order to calculate the difference between the dates. This will give you back a DateInterval object. $last = new DateTime( "25 Dec 2020" ); $now = new DateTime( "now" );

    Làm thế nào để bạn kiểm tra xem một ngày có ít hơn một ngày khác trong PHP không?

    Nếu các ngày đã cho có cùng định dạng, hãy sử dụng toán tử so sánh đơn giản để so sánh các ngày ...
    $ date1 = "2010-01-15" ;.
    $ date2 = "2020-12-14" ;.
    if ($ date1 <$ date2).
    echo "$ date1 là ít hơn $ date2" ;.
    echo "$ date1 lớn hơn $ date2" ;.

    Làm cách nào để kiểm tra xem một ngày có bằng PHP không?

    PHP $ dateone = "2019-10-30";$ datetwo = "2019-10-30";echo "date1 = $ dateone";echo "\ ndate2 = $ datetwo";if ($ dateone == $ datetwo) echo "\ nboth ngày là bằng nhau!";khác lặp lại "Cả hai ngày đều khác nhau!";?>if ($dateOne == $dateTwo) echo "\nBoth the dates are equal!"; else echo "Both the dates are different!"; ?>

    Ngày () làm gì trong PHP?

    Chỉ định định dạng của chuỗi ngày xuất ra.Các ký tự sau có thể được sử dụng: D - Ngày của tháng (từ 01 đến 31). The following characters can be used: d - The day of the month (from 01 to 31)