php 如何在PHP中找到一年中的当前日期?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2121782/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 05:07:48  来源:igfitidea点击:

How to find the current day of the year in PHP?

php

提问by mike

Is there a standard function in PHP that will find the day number of the year based on the current date?

PHP 中是否有标准函数可以根据当前日期查找年份中的天数?

Examples:

例子:

Jan 22nd = 22 
Feb 27th = 58
Mar 5th = 64

If there isn't a standard function, has anyone built anything similar that would handle the conversion? What all is involved?

如果没有标准函数,是否有人构建了类似的东西来处理转换?有什么关系?

回答by Mike

date('z') + 1;

date('z') + 1;

回答by CMS

Use the zformat character of the datefunction:

使用函数的z格式字符date

 echo date('z'); // 22, based on the "current date"

回答by pccFatMan

// get day of year for 08 aug 2008
// result 221
echo date("z", mktime(0,0,0,8,8,2008))+1;