交叉日期选取器问题默认值应为空
Cross Date Picker issue default value should be blank
大家好,我正在使用github的交叉日期选择器代码就像这个
<?php
$date = date("j",strtotime($details['founded'])); // date fetched
$month = date("n",strtotime($details['founded']));
$year = date("Y",strtotime($details['founded']));
?>
HTML
<input type="date" data-initial-day="<?=$date?>" data-initial-year="<?=$year?>" data-initial-month="<?=$month?>" class='TEx_About_allihh' name="estdate" required/>
JS-
<script> $("input[type='date']").cdp();</script>
the src of github is https://github.com/lcnvdl/cross-datepicker
当php日期、月份和年份变量中有值时,一切都很好,但当它们为空时,我希望它们显示默认值,如日期、月份、年份
现在它显示为空白或1。
有时我也希望他们不要有任何价值。
如果你知道如何实现这一点,请告诉我,我也在github上问了一个问题,但没有得到回应
通过我给定的链接并使用其中一个日期选择器,我希望你不会得到这种错误:
日期选择器
使用将成为的null coalescing operator
https://wiki.php.net/rfc/isset_ternary
$temp = (date("j",strtotime($details['founded'])); //try to convert array element to time
if ($details['founded'] != "") { //check if it isn't an empty string
$date = $temp ?? strtotime("now"); //set it to the converted time or set it to the current time
} else {
strtotime("now"); //fallback for an empty string
}
相关文章:
- 我的shareService在angular 2中发送值工作正常,但当我渲染我的另一个组件时,会获得默认值
- jquerydatetimepicker日期和时间应在框默认值中,而无需单击框
- 如果值为空,如何设置输入的默认值?jQuery
- 骨干模型默认值-todos.js示例中不必要的代码
- jquery日期选择器年份范围默认值
- Html5输入属性的默认值,如最小值、最大值、大小等
- 根据两个下拉列表的默认值禁用按钮
- 如何创建具有默认值的JavaScript对象字段?(AngularJS模型相关)
- Angularjs-设置不带ng选项的select的默认值
- jQuery Datepicker从日期开始设置默认值
- 如何设置浏览器打开的文件对话框的文件名(一些默认值)
- JQuery BlockUI鼠标加载光标没有't在Google Chrome中返回默认值
- Selectize选择默认值
- 在KeystoneJS中为Types.Money设置默认值
- 是否可以同时为一个元素的所有事件指定阻止默认值
- 防止在IE7中按回车键时出现默认值
- 如何覆盖jqGrid's语言默认值
- YUI2 颜色选取器默认值问题
- 交叉日期选取器问题默认值应为空
- 我的javascript函数在下拉菜单中选择默认值有什么问题?