php - 如何生成特定日期,例如 3 月 13 日
问题描述
我一直在使用以下代码来生成日期。
$datejoined = strip_tags(date('Y-m-d H:i:s', strtotime("+1 day")));
如何生成 4 月 13 日的具体日期?
解决方案
strtotime()
可以从几乎任何文本行生成日期日期。
strtotime('April 13')
当年 4 月 13 日可以。使用以下代码行对其进行测试:
print date('Y-m-d H:i:s', strtotime('April 13'));
但我个人建议您使用更快的功能mktime()
:
mktime(0, 0, 0, 4, 13); // 0:00:00, 4th month, 13 day, [current year].
推荐阅读
- node.js - 重写 npm 脚本以兼容 windows cmd
- regex - 我在 JENKINS 中的 MM/DD/YYYY 正则表达式有什么问题
- pandas - 通过布尔分隔符拆分 numpy 数组/熊猫数据帧
- java - 如何在嵌套的 SELECT 查询中使用 BeanMapHandler 与字段到列的映射,键为 ID?
- google-sheets - 需要按字符串和优先级对列进行排序
- node.js - 使用中间件表达静态需要登录
- github - How to host image at https://user-images.githubusercontent.com/{path}/{filename}?
- php - 文件中存在数据时 Laravel 导入验证错误
- java - Java Enum type naming convention
- php - I was able to save emojis in my database but when I retrieve it, it shows unicodes