PHP:将一年中的某一天转换为月份和月份中的某一天 [英] PHP: Convert Day of Year to Day of Month and Month

查看:32
本文介绍了PHP:将一年中的某一天转换为月份和月份中的某一天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果你有一年中的一天.你怎么能把它转换成月份和月份的日期?例如:144"日应转换为 5 月 26 日.我想我还必须添加实际年份来解释闰年.但我什么也没找到.

If you have the day of the year. How can you convert that to day of month and month? For example: The day "144" should be converted to 26th of May. I guess I also have to add the actual year to account for leap years. But I haven't found anything at all.

例如函数 mktime() 期望月、年和日月.

For example the function mktime() exepects the month, year and day of month.

大家有什么建议吗?

推荐答案

strtotime("January 1st +".($days-1)." days");

这将返回对应于一年中指定日期的时间戳.

This will return a timestamp corresponding to the specified day of the year.

这篇关于PHP:将一年中的某一天转换为月份和月份中的某一天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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