How do I calculate the difference between two dates in hours? For example: day1=2006-04-12 12:30:00 day2=2006-04-14 11:30:00 In this case the result should be 47 hours. The newer PHP-Versions provide some new classes called DateTime , DateInterval , DateTimeZone and DatePeriod . The cool thing about this classes is, that it considers different timezones, leap years, leap seconds, summertim
我如何计算两个日期之间的差异? 例如: day1=2006-04-12 12:30:00 day2=2006-04-14 11:30:00 在这种情况下,结果应该是47小时。 较新的PHP版本提供了一些称为DateTime , DateInterval , DateTimeZone和DatePeriod新类。 关于这个类的很酷的事情是,它考虑了不同的时区,闰年,闰秒,夏季等。最重要的是,它非常易于使用。 下面是你想要的这个对象的帮助: // Create two new DateTime-objects... $date1 = new DateTi
I need some help about time formatting. The input I get from a file is (for example): Wed Jun 28 19:12:55 CEST 2015, so: name of the day Month(text) Day Hour:minute:second Timezone Year. I would like to convert it to Mysql datetime format, to be able to store in a database. The format is (for example): 2016-03-06 12:09:44, which is Year-Month (number)-Day Hour-Minute-Second Thank you! Y
我需要一些关于时间格式的帮助。 我从文件中得到的输入是(例如):Wed Jun 28 19:12:55 CEST 2015,例如:当天的名称月份(文本)日时:分:秒时区年。 我想将它转换为Mysql日期时间格式,以便能够存储在数据库中。 格式是(例如):2016-03-06 12:09:44,这是年 - 月(数) - 日小时 - 分 - 秒 谢谢! 你可以使用php的日期函数。 echo date("Y-m-d h:i:s",strtotime($yourDateTimeVariable)); 有关更多帮助,请参
This question already has an answer here: Filter XML by elements [duplicate] 2 answers Use this function: function humanTiming ($time) { $time = time() - $time; if ($time > 3600) { return date("y/m/d h/i", $time); } else { $tokens = array ( 31536000 => 'year', 2592000 => 'month', 604800 => 'week', 864
这个问题在这里已经有了答案: 按元素过滤XML [复制] 2个答案 使用此功能: function humanTiming ($time) { $time = time() - $time; if ($time > 3600) { return date("y/m/d h/i", $time); } else { $tokens = array ( 31536000 => 'year', 2592000 => 'month', 604800 => 'week', 86400 => 'day', 3600 =&
Possible Duplicate: PHP How to find the time elapsed since a date time? How would I get the time ago posted. Just example 3 minutes ago or more than 24 hours ago and 2 days ago out of 2012-07-13 17:55:59. <?php function get_timeago( $ptime ) { $etime = time() - $ptime; if( $etime < 1 ) { return 'less than 1 second ago'; } $a = array( 12 * 30 * 24 * 60 * 6
可能重复: PHP如何查找自日期时间以来的时间? 我如何得到时间之前张贴。 只是例如3分钟前或超过24小时前和2天前超出2012-07-13 17:55:59。 <?php function get_timeago( $ptime ) { $etime = time() - $ptime; if( $etime < 1 ) { return 'less than 1 second ago'; } $a = array( 12 * 30 * 24 * 60 * 60 => 'year', 30 * 24 * 60 * 60 => 'month',
ok i have a date date('Y-m-d H:i:s'); how can we make it like 0 seconds ago or x year x month x day x minutes x seconds ago ? but without useing the str_time ( php 5.3.3 ) edit* i mean is some.date - time.now = someyear some month someday someminutes someseconds ago. like facebook or stackoverflow ( updated. i mean like that. – Adam Ramadhan 2 mins ago edit ) edit* some say to use sktim
好的,我有个约会 date('Y-m-d H:i:s'); 我们怎么能使它像0秒前或x年x月x日x分钟x秒前? 但不使用str_time(php 5.3.3) 编辑* 我的意思是some.date - time.now =几年前某个月的某个月。 像facebook或者stackoverflow(更新,我的意思是这样 - Adam Ramadhan 2 mins ago编辑) 编辑*有人说使用sktime? 2分钟前。 谢谢 亚当拉马丹 你应该试试这个(看起来完全像克劳克的答案,但这个是固定的!) <?php
Hi i am doing internal mail service application , i have the field called datetime in my table, i want to show the mail datetim in the inbox view somthing like gmail inbox, i want to show if the mail came just 10 min aga means , i want to show 10min ago, if mail came around 2 days back means i want to show the DATE-Time , Thing keep in mind i maintain the DATETIME datatyoe , Thanks Bh
嗨,我正在做内部邮件服务应用程序, 我的桌子上有叫datetime的字段, 我想在Gmail收件箱的收件箱视图中显示邮件日期, 我想表明,如果邮件只来了10分钟aga的意思,我想显示10分钟前, 如果邮件在2天左右到来意味着我想显示日期时间, 记住我维护DATETIME datatyoe, 感谢Bharanikumar 这是我的片段... list($ date,$ time)= explode('',$ session_time); list($ year,$ month,$ day)= expl
I have 2 time() values, for example: 1379078542 1379078574 How do I work out their diffidence and display the output as years, months, weeks, days, hours, minutes, seconds etc. The 2 values above have a difference of 32 seconds I think, so in this case, I would want to display 32 seconds. $datetime1 = new DateTime('@1379078542'); $datetime2 = new DateTime('@1379078574'); $interval = $dateti
我有2个时间()值,例如: 1379078542 1379078574 我该如何解决他们的问题,并将输出显示为年,月,周,日,小时,分钟,秒等。 上面的2个值有32秒的差别,所以在这种情况下,我想显示32秒。 $datetime1 = new DateTime('@1379078542'); $datetime2 = new DateTime('@1379078574'); $interval = $datetime1->diff($datetime2); $elapsed = $interval->format('%y years, %m months, %a days, %h hours, %i minutes
I have timestamps in the following format: 2013-10-19 18:47:30 I am using this to convert to relative (x minutes, hours, days ago) time but it returns nothing for the most recent users, I assume because my system time is GMT -3 hours so it is interpreting it as a time in the future. If that is the case, how can I take the users GMT offset into account in the result? $time = strtotime('2013-04
我有以下格式的时间戳:2013-10-19 18:47:30 我使用它来转换为相对(x分钟,几小时,几天前)时间,但它对于最近的用户没有任何回报,我假设因为我的系统时间是GMT -3小时,所以它将它解释为未来的时间。 如果是这样的话,我怎样才能在结果中考虑GMT偏移量? $time = strtotime('2013-04-28 17:25:43'); echo 'event happened '.humanTiming($time).' ago'; function humanTiming ($time) { $time = time() - $time; /
Possible Duplicate: PHP: producing relative date/time from timestamps Given a specific DateTime value, how do I display relative time, like 35 minutes ago 2 hours ago 3 days ago 1 month ago etc, etc...? mysql_query("UPDATE users SET lastlogin = ".time()." WHERE id = ".$userID); this may help you function time_ago_en($time) { if(!is_numeric($time)) $time =
可能重复: PHP:从时间戳生成相对日期/时间 给定一个特定的日期时间值,我如何显示相对时间,如 35分钟前 2小时前 3天前 1个月前 等等......? mysql_query("UPDATE users SET lastlogin = ".time()." WHERE id = ".$userID); 这可能会帮助你 function time_ago_en($time) { if(!is_numeric($time)) $time = strtotime($time); $periods = array("second", "minute", "hour"
I have a SQL Datestamp like this: 2012-02-20 21:14:54 How would I print out the relative date and time in PHP? eg Occured: a few seconds ago Occured: 4 minutes ago Occured: 4 hours ago Occured: Monday Jan 8th, 2012 After the hours I just want to print out the actual date Found this after two seconds of Google http://www.mdj.us/web-development/php-programming/another-variation-on-the-tim
我有这样的SQL Datestamp:2012-02-20 21:14:54 我如何在PHP中打印出相关的日期和时间? 例如 发生:几秒钟前发生:4分钟前发生:4小时前发生:2012年1月8日,星期一 几小时后我只想打印出实际的日期 Google两秒钟后发现此问题http://www.mdj.us/web-development/php-programming/another-variation-on-the-time-ago-php-function-use-mysqls-datetime-field-type 一般情况下,您选择的时间单位为秒,测试时差是否小