[英]Get current date and time form mktime in PHP
我有一個問題,找到過去mktime
的當前日期。 在PHP中,我使用date("j");
找到當前日期date("j");
。 在這里我需要,假設我的日期在過去的一年中像mktime(0, 0, 0, 2, 1, 2008)
,那么我在這里如何找到這個特定的過去一個月的當前日期。
嘗試這個:
$date = getdate(mktime(0, 0, 0, 2, 1, 2008));
$day = $date['mday'];
要不就:
$day = date('j', mktime(0, 0, 0, 2, 1, 2008))
要么是@ octern的解決方案,要么你可以做到
$day = date('j', strtotime("-2 months"));
要么
$day = date('j', strtotime('-30 days'));
根據您的需要。
您可能還想參考strtotime()
手冊。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.