如何在下拉列表中获取所有天、月和年?
是否有一个类或 php 脚本会在所有天、月、年中在下拉字段中回显。我需要将它们用于出生日期字段。我用谷歌搜索,但没有发现任何我可以实施或学习的内容。有什么想法吗?谢谢
Is there a class or a php script that will echo in drop down fields all the days, months, and years. I need to use them for date of birth fields. I googled but nothing came up that i can implement or learn from. ANy ideas? thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您真的只想在 PHP 中完成,这里有一个简单的开始:
另一种方法,类似的输出:
(年份将按升序排列,而不是降序排列)
If you REALLY just want it done in PHP, here's a simple start:
Another method, similar output:
(Years will be in Ascending order, rather than Descending)
为什么不使用一些基于 Javascript 的日历小部件,而不是使用三个不同的
例如,我多次听说过 jQuery Datepicker --效果要好得多,你不觉得吗:
(来源:pascal-martin.fr)
(这只是我链接到的页面上演示的屏幕截图;您可以调整多个选项)
Instead of going with three distinct
<select>
, which is not a very user-friendly solution, why not use some Javascript-based calendar widget ?For example, I've heard about jQuery Datepicker quite a few times -- the effect is far better, don't you think :
(source: pascal-martin.fr)
(And that's just a screenshot of the demo on the page I linked to ; there are several options you can tune)
该主题很旧,但会在接受的答案中说要添加
-->;
因为在 29 日、30 日和 31 日标签将是错误的。 PHP 将当前日期作为默认值,并且将返回缺少这一天的错误月份。 PHP 会将其解释为月份 + 1 天并显示下个月
The topic is old, but would say in the accepted answer to be added
-->
because on 29th, 30th and 31st the labels would be wrong. PHP takes as default the current day and will return wrong months in which this day is missing. PHP will interprete it as the month + 1 day and will show the following month
我知道这是一个老问题,但也许这会有所帮助。
http://php.net/manual/en/function.cal-info。 php
http://php.net/manual/en/ref.calendar .php
I know that this is an old question but maybe this would help.
http://php.net/manual/en/function.cal-info.php
http://php.net/manual/en/ref.calendar.php