当前凌晨时间戳

echo strtotime(date(‘Y-m-d‘));
 
获取明天凌晨的时间戳
代码:echo strtotime(date(‘Y-m-d‘,strtotime(‘+1 day‘)));
 
附上测试代码:
echo strtotime(‘2012-11-2‘);
echo strtotime(‘2012-11-2 00:00:00‘);
echo strtotime(date(‘Y-m-d‘)),‘
‘;
echo date(‘Y-m-d H:i:s‘,strtotime(date(‘Y-m-d‘)));
echo strtotime(date(‘Y-m-d‘,strtotime(‘+1 day‘)));
echo ( strtotime(date(‘Y-m-d‘,strtotime(‘+1 day‘))) - strtotime(date(‘Y-m-d‘)) )/3600;
 
其它参考代码:
 
echo "一周后:".date("Y-m-d",strtotime("+1 week"));     
echo "一周零两天四小时两秒后:".date("Y-m-d G:H:s",strtotime("+1 week 2 days 4 hours 2 seconds"));     
echo "下个星期四:".date("Y-m-d",strtotime("next Thursday"));     
echo "上个周一:".date("Y-m-d",strtotime("last Monday"));     
echo "一个月前:".date("Y-m-d",strtotime("last month"));     
echo "一个月后:".date("Y-m-d",strtotime("+1 month"));     
echo "十年后:".date("Y-m-d",strtotime("+10 year"));

时间: 2024-08-04 15:28:37

当前凌晨时间戳的相关文章

php 计算当天凌晨时间戳 以及获取其他常用时间戳

php 计算当日凌晨时间戳 以及获取其他常用时间戳(持续补充中...) 获取当天凌晨时间戳: echo strtotime(date('Y-m-d')); 以下再列举一些获取其他常用时间戳的方法 获取明天凌晨的时间戳 echo strtotime(date('Y-m-d',strtotime('+1 day'))); 获取指定时间字符串的时间戳: echo strtotime('2012-11-2'); echo strtotime('2012-11-2 00:00:00'); echo str

PHP 获取当天 凌晨 时间戳常用代码

echo strtotime(date('Y-m-d')); 获取明天凌晨的时间戳 代码:echo strtotime(date('Y-m-d',strtotime('+1 day'))); 附上测试代码: echo strtotime('2012-11-2'); echo strtotime('2012-11-2 00:00:00'); echo strtotime(date('Y-m-d')),' '; echo date('Y-m-d H:i:s',strtotime(date('Y-m-

iOS 时间戳操作

我们在开发中会遇到各种对于时间戳的操作,这里分享下比较常用的几种. 1.当前时间戳 1 NSString *timeSp = [NSString stringWithFormat:@"%ld", (long)[[NSDate date]timeIntervalSince1970]]; 2 NSLog(@"现在时间戳%@",timeSp); 2.今天凌晨时间戳  (直接复制粘贴该方法即可,返回值即为今天凌晨时间戳) 1 #pragma mark 今天凌晨时间戳 2 3

NSDate 时间戳与字符串转换

一,转化的方法为 NSString *timeSp = [NSString stringWithFormat:@"%d", (long)[localeDate timeIntervalSince1970]]; NSLog(@"timeSp:%@",timeSp); //时间戳的值 二,把获取的时间转化为当前时间 NSDate *datenow = [NSDate date];//现在时间,你可以输出来看下是什么格式 NSTimeZone *zone = [NSTim

时间计算的思考

有个人问能不能获取 小时的时间戳(针对于一天的24小时来说),而不是对于1970年 琢磨着感觉是从零点开始到现在的秒数.该问题的解决方案有多种 1.通过时分秒计算,得到时分秒 然后 时乘以3600 + 分乘以60 + 秒 可以得到 代码如下 <?php $time=time();//获取当前时间戳 $array=explode(':',date("H:i:s",$time));//得到时分秒 $hex=array(3600,60,1);//赋值时分秒的乘积进制 $result=0

php l练习(写着玩)

需求:假设今天24号,今天发表的评论显示几小时前发布,23号发布的显示 昨天几点发布的,再往前的就直接显示年月日. date_default_timezone_set('PRC'); // $create_time = 1561377423; $create_time = 1561219392; // $create_time = 1561132890; //最又那种形式: //获取凌晨时间戳 $start = date('Y-m-d'); $start_time = strtotime($st

【Python】Python判断统计每个月天数源码示例

如何利用Python判断统计每个月天数源.在日常的学习或是工作中会经常遇到需要统计日期数据的情况.特别是统计涉及到自然周或是自然月的计算. 用Python编程语言来统计这些是需要考虑很多条件的.例如:自动运行的时候我们需要判断每个月的天数,而且对于自然月的加减,还要考虑跨年的自然月与是否闰年.这是一个用python写的小程序,可以计算自然周与自然月.是通过时间戳计算,返回时间戳:如果计算天则返回当天凌晨的时间戳:如果计算周则返回当周周一的凌晨时间戳:自然月则返回当月1日凌晨时间戳. 代码不是很好

PHP 判断给定两个时间是否在同一周,月,年

判断是否在同一周 date_default_timezone_set('PRC'); //判断是否在同一周,原理:求出其中一个时间戳所在周的周一凌晨时间戳和周日24.00时间戳,如果另一个时间戳在这个范围内,则说明在同一周,否则不在同一周 function getSameWeek($pretime,$aftertime){ $monday = strtotime('last Monday', $pretime); //离当前时间戳$pretime最近的上一个周一的时间戳,如果当前时间$preti

获取明天凌晨的时间戳

在一些业务逻辑中,需要在今天获取明天凌晨的时间戳.在网上找了一下别人的写法是这样的 echo strtotime(date('Y-m-d',strtotime('+1 day'))); 这样的写法是比较保守的做法,阅读起来是先将今天时间戳加一天,然后取年月日,然后转时间戳. 我提出了一种稍微改进的做法 echo strtotime(date("Y-m-d"))+86400; 这样能少调用一次函数实现加一天,毕竟一天的常规情况下是有86400秒的.tips:我记得有一次出现了一分钟61秒