因此,假设我有一个能够选择月份中特定日期的用户。假设他愿意选择2014年10月16日,那么我想将每月剩余的日期显示为日历。
<?php
error_reporting(0);
$data = $_POST['input'];
$days = array('Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday');
$m = date('m'); $y = date('y');
$d = cal_days_in_month(CAL_GREGORIAN,$m,$y);
for ($i=1;$i<;$i++){
echo $i + 1;
}
到目前为止,代码还很混乱。我没有办法解决这个问题,这就是为什么我问。
对于格式,date
可以使用以下命令:
't'
给定月份中的天数(28到31)
'j'
,每月中没有前导零(1到31)的天数
<?php
$timestamp = strtotime('2014-10-03');
$daysRemaining = (int)date('t', $timestamp) - (int)date('j', $timestamp);
var_dump($daysRemaining); // int(28)
编辑:显然您想列出一个月中的剩余天数:
<?php
$timestamp = strtotime('2014-10-03');
$yearMonth = date('Y-m-', $timestamp);
$daysInMonth = (int)date('t', $timestamp);
for ($i = (int)date('j', $timestamp); $i <= $daysInMonth; $i++) {
$dateString = date('l \t\h\e jS \o\f F', strtotime($yearMonth . $i));
var_dump($dateString);
}
/*
string(25) "Friday the 3rd of October"
string(27) "Saturday the 4th of October"
string(25) "Sunday the 5th of October"
string(25) "Monday the 6th of October"
string(26) "Tuesday the 7th of October"
string(28) "Wednesday the 8th of October"
string(27) "Thursday the 9th of October"
string(26) "Friday the 10th of October"
string(28) "Saturday the 11th of October"
string(26) "Sunday the 12th of October"
string(26) "Monday the 13th of October"
string(27) "Tuesday the 14th of October"
string(29) "Wednesday the 15th of October"
string(28) "Thursday the 16th of October"
string(26) "Friday the 17th of October"
string(28) "Saturday the 18th of October"
string(26) "Sunday the 19th of October"
string(26) "Monday the 20th of October"
string(27) "Tuesday the 21st of October"
string(29) "Wednesday the 22nd of October"
string(28) "Thursday the 23rd of October"
string(26) "Friday the 24th of October"
string(28) "Saturday the 25th of October"
string(26) "Sunday the 26th of October"
string(26) "Monday the 27th of October"
string(27) "Tuesday the 28th of October"
string(29) "Wednesday the 29th of October"
string(28) "Thursday the 30th of October"
string(28) "Friday the 31st of October"
*/
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句