簡體   English   中英

日期與strtotime無法正常工作-PHP

[英]date with strtotime not working properly - php

我無法使用strtotime函數使此日期正常運行。 我需要將日期轉換為“ d / m / Y”。 我從數據庫中正確獲取了日期,但是它沒有轉換為新的日期格式,而是僅在$ row [saleDate]中回顯帶有日期的所有內容。

這是代碼:

    echo "<tr><td class='contentTd'> $row[saleNumber] </td>
            <td class='contentTd'> $row[saleValue] </td>
            <td class='contentTd'> $row[paymentMethod] </td>
            <td class='contentTd'> $row[sellerName] </td>
            <td class='contentTd'> date('d/m/Y', strtotime($row[saleDate])); 
            </td></tr>";

你能幫我一下嗎?

使用串聯顯示日期。

      echo "<tr><td class='contentTd'> $row[saleNumber] </td>
        <td class='contentTd'> $row[saleValue] </td>
        <td class='contentTd'> $row[paymentMethod] </td>
        <td class='contentTd'> $row[sellerName] </td>
        <td class='contentTd'>".' date('d/m/Y', strtotime($row[saleDate]);'. 
        "</td></tr>";

我認為您忘記了date()函數或strtotime()函數

我發現了錯誤:strtotime函數內缺少引號。

echo "<tr><td class='contentTd'> $row[saleNumber] </td>
            <td class='contentTd'> $row[saleValue] </td>
            <td class='contentTd'> $row[paymentMethod] </td>
            <td class='contentTd'> $row[sellerName] </td>
            <td class='contentTd'>" . date('d/m/Y', strtotime("$row[saleDate]")) . "</td></tr>";

現在一切正常!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM