将日期选择器设置为给定日期 [英] Set date picker to a given date

查看:126
本文介绍了将日期选择器设置为给定日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法将datepicker设置为给定的日期?



我已经尝试过:

 < input type = datename =dobvalue =<?php echo date('yyyy-mm-dd',escape($ user-> data() - > dob));?>/> 

但不行。



我只是想知道是否可行,但不能仅仅设置为现在。我可以看到在线唯一的帮助是字符串操作,但实际上并没有设置datepicker。

解决方案

您可以使用datepicker(
setDate,$$$$$$$ <?php echo date('Ym-d')
);

您还需要检查datepicker中日期的格式。



或者你可以这样做:

 < input type =datename =dob
value =<?php echo date('Ym-d',strtotime(escape($ user-> data() - > dob)));?>/>

您还需要添加strtotime函数。


Is there a way to set a datepicker to a given date?

I have tried this:

<input type="date" name="dob" value="<?php echo date('yyyy-mm-dd', escape($user->data()->dob)); ?>"/>

but it doesn't work.

I just want to know if it is possible, but it can't just be set to 'now'. The only help I can see online is string manipulation, but not actually setting the datepicker.

解决方案

You can set the date by using the datepicker function:

$("input[type=date]").datepicker(
    "setDate", "<?php echo date('Y-m-d')"
);

You need to check the format also of date in datepicker.

Or You can do this:

<input type="date" name="dob" 
value="<?php echo date('Y-m-d', strtotime(escape($user->data()->dob))); ?>"/>

You need to add the strtotime function also.

这篇关于将日期选择器设置为给定日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆