如何查询本周是星期几的时间点?
- 内容介绍
- 文章标签
- 相关推荐
本文共计103个文字,预计阅读时间需要1分钟。
pythondef this_week(week=1, is_return_timestamp=True): if not 1 <=week <=7: return False if is_return_timestamp: return f获取本周第{week}天 else: return f本周第{week}天
/** * 获取本周几时间 * @param int $week 1-7 周一到周日 * @param bool $is_return_timestamp 是否返回时间错 * @return false|int|string */ function this_week($week = 1, $is_return_timestamp = true) { $monday = strtotime("last Monday"); if (date('N') === '1') $monday = strtotime(date('Y-m-d')); $monday += ($week - 1) * 86400; $monday = $is_return_timestamp ? $monday : date('Y-m-d H:i:s', $monday); return $monday; }
本文共计103个文字,预计阅读时间需要1分钟。
pythondef this_week(week=1, is_return_timestamp=True): if not 1 <=week <=7: return False if is_return_timestamp: return f获取本周第{week}天 else: return f本周第{week}天
/** * 获取本周几时间 * @param int $week 1-7 周一到周日 * @param bool $is_return_timestamp 是否返回时间错 * @return false|int|string */ function this_week($week = 1, $is_return_timestamp = true) { $monday = strtotime("last Monday"); if (date('N') === '1') $monday = strtotime(date('Y-m-d')); $monday += ($week - 1) * 86400; $monday = $is_return_timestamp ? $monday : date('Y-m-d H:i:s', $monday); return $monday; }

