【PHP中时间戳与日期之间的转换程序_PHP教程】教程文章相关的互联网学习教程文章

请教前辈时间戳用php转换成日期和用mysql函数转换成日期不一致的问题

mysql数据库有一表infor,该表下有一字段为time字段,类型为int(10),该字段下有一条数据位:1383346800 问题来了: 我用php函数echo date("Y-m-d H:i:s",1383346800); 运行结果是:2013-11-01 23:00:00 而用mysql函数select from_unixtime(1383346800); 运行结果是:2013-11-02 07:00:00 如图: 为何同一个时间戳php和mysql是两个结果?哪个结果才是对的? 求前辈帮看下,两种方法我都需要,因为我要用这...

请教如何把新浪微博接口返回的时间转换为时间戳.格式内详

新浪微博 接口 时间戳 Fri Jun 07 18:27:54 +0800 2013 从新浪接口返回的时间格式是这样的 想转换为时间戳 求教比较简单效率的方法 谢谢 回复讨论(解决方案) ? 试了下strtotime 可以用.... 思维误区了.. ? 试了下strtotime 可以用.... 思维误区了.. 解决就好~ 以前我2过,也是通过人家提供的接口返回给我xml, 然后我通过正则匹配的xml里面自己想要的东西,再后来我发现php有xml的解析函数! 不过,很...

php时间戳问题

php函数中的date函数在某些系统(如 Windows)中限制为从 1970 年 1 月 1 日到 2038 年 1 月 19 日。 现在我有个时间戳是超过了2038年后,用date不能正常转化成正确的标准时间格式。 还有一个问题就是我有个时间戳1356969600,转化成正常效果是2013-1-1 00:00:00 例子 $dt = new DateTime(@1356969600);echo $dt->format(Y-m-d H:i:s); 通过例子转化却变成了2012-12-31 16:00:00,比正常效果足足少了八个小时 ...

PHP时间戳取整问题

时间戳是10位的,取的是当前时间戳: $nowtime = strtotime(date('Y-m-d H:i:s')); //当前时间戳 得到的 $nowtime 有时候是 1393834011,有时候是 1393834062 我想实现一功能,怎么样能让时间戳取整变成这样的:1393834020,1393834070? 不能直接这么写:strtotime(date('Y-m-d H:i')); 回复讨论(解决方案) $time=time(); $time=$time/10; $time_zhengshu=floor($time); $time_zhengshu=$time_zhengs...

求一个时间戳

请大神,写一条php语句,打印: “下周一10:20”的时间戳 回复讨论(解决方案) echo strtotime(date(Y-m-d 10:20:00, strtotime(next week))); echo strtotime(date(Y-m-d 10:20:00, strtotime(next week))); 呵呵,这个是以现在的时间加一周的结果;直接执行后,是下周二的10:20 是吗? 我有忽悠你的必要吗? sorry,我的错,给分了!

php获取当月/某月最后一天的时间戳

public function getendmouthtime() { $date=date("Y-m",time()); $date_arr=explode(-,$date); $year=$date_arr[0]; $month=$date_arr[1]; $days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); if ($month < 1 OR $month > 12) { return 0; } // Is the year a leap year? ...

请问怎么得到本周、上周、本月、上月开始和结束的时间戳

请问怎么得到本周、上周、本月、上月开始和结束的时间戳 回复讨论(解决方案) echo date("Ymd",strtotime("now")), "\n"; echo date("Ymd",strtotime("-1 week Monday")), "\n"; echo date("Ymd",strtotime("-1 week Sunday")), "\n"; echo date("Ymd",strtotime("+0 week Monday")), "\n"; echo date("Ymd",strtotime("+0 week Sunday")), "\n"; //date(n) 第几个月 //date("w") 本周周几 //date...

怎样把时间戳转换成其它格式

$conn = mysql_connect("localhost","root","qqaazz"); mysql_select_db("2",$conn); mysql_query("SET NAMES GBK"); $sql = "SELECT * FROM `yang_user` WHERE `fullname` = 'qqaazz'"; $result=mysql_query($sql,$conn); while($row=mysql_fetch_assoc($result)) { echo"".$row["uid"]."".$row["uname"]."".$row["utype"]."".$row["email"]."".$row["regtime"].""; } ?> 这段代码获得的regtime是1433...

php日期和时间基础知识Unix时间戳

输出1396193923对应的日期echo date("Y-m-d",'1396200000')/*取得日期的Unix时间戳UNIX 时间戳(英文叫做:timestamp)是 PHP 中关于时间与日期的一个很重要的概念,它表示从 1970年1月1日 00:00:00 到当前时间的秒数之和。PHP提供了内置函数strtotime实现功能:获取某个日期的时间戳,或获取某个时间的时间戳*/echo strtotime('2015-7-27');//1437926400,这个数字表示从1970-1-1到2015-7-27经历了1437926400秒echo strtotime('201...

php中时间戳和日期格式的转换

一,PHP时间戳函数获取指定日期的unix时间戳 strtotime(”2009-1-22″) 示例如下:echo strtotime(”2009-1-22″) 结果:1232553600说明:返回2009年1月22日0点0分0秒时间戳二,PHP时间戳函数获取英文文本日期时间 示例如下:便于比较,使用date将当时间戳与指定时间戳转换成系统时间(1)打印明天此时的时间戳strtotime(”+1 day”)当前时间:echo date(”Y-m-d H:i:s”,time()) 结果:2009-01-22 09:40:25指定时间:echo date(”Y-...

PHP浮点数时间戳转正常int型

PHP浮点数时间戳转正常int型做七牛云存储的时候,获取了一个文件列表,然后里面的文件上传时间返回值居然是double型的,如:1.3800892861427E+16这怎么办?开始我用intval 转了 发现是64位的整形,不好弄,后来询问了先截取后处理才能正确返回时间戳:$a = 1.3800892861427E+16; $a = strval($a); $a = substr($a,0,11); $a = bcmul($a,1000000000); //$a显示为了 1380089286 后面用date就好了

PHP获取本周本月第一天、最后一天时间戳的代码

获取本周第一天/最后一天的时间戳$year = date("Y");$month = date("m");$day = date(w);$nowMonthDay = date("t");$firstday = date(d) - $day;if(substr($firstday,0,1) == "-"){$firstMonth = $month - 1;$lastMonthDay = date("t",$firstMonth);$firstday = $lastMonthDay - substr($firstday,1);$time_1 = strtotime($year."-".$firstMonth."-".$firstday);}else{$time_1 = strtotime($year."-".$month."-".$firstday);}$last...

PHP时间戳函数总结

PHP语言中的函数有许多种,各种应用方式不同,实现的功能也不尽相同。我们在本文种为大家总结了PHP时间戳函数,希望能作为参考学习对象。一、PHP时间戳函数获取指定日期的unix时间戳 strtotime(”2009-1-22″) 示例如下:echo strtotime(”2009-1-22″) 结果:1232553600说明:返回2009年1月22日0点0分0秒时间戳二、PHP时间戳函数获取英文文本日期时间 示例如下:便于比较,使用date将当时间戳与指定时间戳转换成系统时间(1)打印明...

php获取今天明天昨天时间戳的方法总结

php 获取今天明天昨天时间戳的 N 种方法总结,php获取今天,昨天,明天的时间的方法总结如下:header("Content-type:text/html;charset=utf-8"); //-------------------------------------------------------------------------------- date_default_timezone_set(Asia/Shanghai); echo ;echo 今天:,date(Y-m-d),;echo 昨天:,date(Y-m-d,strtotime(-1 day)),;echo 昨天:,date(Y-m-d,strtotime(yesterday)),;echo 明天:,date(Y-m-d,...

php常用的时间戳

strtotime(now)strtotime(today)strtotime(tomorrow)strtotime(yesterday)strtotime(date(Y-m-d, strtotime(+1 day)))strtotime(tomorrow) - time()strtotime(”2009-1-22″)strtotime(”+1 day”)date(”Y-m-d H:i:s”,time())date(”Y-m-d H:i:s”,strtotime(”+1 day”))strtotime(”-1 day”)date(”Y-m-d H:i:s”,time()) date(”Y-m-d H:i:s”,strtotime(”-1 day”))strtotime(”+1 week”)date(”Y-m-d H:i:s”,strtotime(...