问题描述
我一直在网上浏览示例,我发现它们有点神秘或矫枉过正.
I have been looking through examples online, and I am finding them a bit cryptic or overkill.
我需要做的是这样的:
$timestamp = time();
然后找出这一天是星期一还是月初?
and then find out if the day is a Monday or a fist of the month?
我确信这是可能的,我只是不知道该怎么做.
I am sure it is possible, I am just not sure how to do that.
推荐答案
其实你不需要时间戳变量,因为:
Actually, you don't need timestamp variable because:
摘自date函数的php.net:
Exerpt from date function of php.net:
返回根据给定格式字符串格式化的字符串给定的整数时间戳或当前时间(如果没有时间戳)给定的.换句话说,timestamp 是可选的,默认为该值时间().
Returns a string formatted according to the given format string using the given integer timestamp or the current time if no timestamp is given. In other words, timestamp is optional and defaults to the value of time().
if(date('j', $timestamp) === '1')
echo "It is the first day of the month today
";
if(date('D', $timestamp) === 'Mon')
echo "It is Monday today
";
这篇关于PHP - 如何使用 $timestamp 检查今天是星期一还是本月的第一天?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!



大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)