strtotime

Converting day of week to dates for the current month with MYSQL & PHP

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 13:41:43
问题 Spent a while searching and couldn't find any answers. Really simple question I hope. In my database I have a string column dayOfWeek. I use this to track what day of week weekly events are scheduled for. Usually I match the dayOfWeek to the current day using PHP and display the correct events. What I want to do is show a calendar into the future which makes a list of the future dates of the weekly recurring event. For example, if the event takes place on Tuesday, and Feb 2017 has Tuesdays on

Strange behaviour of strtotime() when using relative dates ('this week')

和自甴很熟 提交于 2019-12-06 11:12:43
问题 I've encountered somehow weird behavior of the strtotime() function when dealing with relative date formats. I live in a country, where the first day of the week isn't Sunday but Monday instead. This fact should reflected on strtotime() 's output. The problem is, that no matter what locale I set (i tried en_US locale too), strtotime() just weirds out and neither Monday nor Sunday appears to be in this week's range. See example below. Today, 2014-02-02 (or 02/02/2014, if you will .. what a

PHP时间戳相互转换

北城以北 提交于 2019-12-06 11:02:15
1、获取当前时间方法date() 很简单,这就是获取时间的方法,格式为:date(format,format,timestamp),format为格式、timestamp为时间戳–可填参数。 2、获取时间戳方法time()、strtotime() 这两个方法,都可以获取php中unix时间戳,time()为直接获取得到,strtotime(time,time,now)为将时间格式转为时间戳,$time为必填。清楚了这个,想了解更多,请继续往下看。 3、 date($format)用法 比如: echo date(‘Y-m-d’) ,输出结果:2012-03-22 echo date(‘Y-m-d H:i:s’),输出结果:2012-03-22 23:00:00 echo date(‘Y-m-d’, time()),输出结果:2012-03-22 23:00:00(结果同上,只是多了一个时间戳参数)(时间戳转换为日期格式的方法) echo date(‘Y’).’年’.date(‘m’).’月’.date(‘d’).’日’,输出结果:2012年3月22日 举例就这几个,只是格式的变通而已,下面是格式中各个字母的含义: /****格式中可使用字母的含义****/ a - “am” 或是 “pm” A - “AM” 或是 “PM” d - 几日,二位数字,若不足二位则前面补零; 如:

How to calculate the the interval between 2 unix timestamps in php WITHOUT dividing by 86400 (60*60*24)

流过昼夜 提交于 2019-12-06 04:23:27
问题 I have 2 unix timestamps, Im in AsiaPacific/Auckland timezone (GMT+12, DaylightSavings = GMT+13) I want to calculate the number of days interval between 2 timestamps, where one is inside daylight savings time and one is not. My example dates are 7 Feb 2009 (1233925200) to 21 September 2010 (1284985360) (not including 21st) see here it says 591 days: http://www.timeanddate.com/date/durationresult.html?d1=7&m1=2&y1=2009&d2=21&m2=9&y2=2010 Lets calculate, here are my timestamps (both are based

php date less than another date

孤者浪人 提交于 2019-12-05 20:13:44
问题 given this kind of date object date("m/d/Y", strtotime($numerical." ".$day." of ".date("F"))) where it may give a mm/dd/yyyy day that is the "first Monday of August", for instance how can I decide if this date is greater than, less than, or equal to today's date? I need a now() method that works in this format and can be compared between date objects I haven't tried date() < date() , yet. But I don't think that will work any insight appreciated 回答1: Compare the timestamps: if (strtotime(

PHP weekdays of current week, why is date() and strtotime taking next week?

陌路散爱 提交于 2019-12-05 18:52:46
I am using the following code to get a Y-m-d format of weekdays: $monday = date('Y-m-d', strtotime('Monday')); $tuesday = date('Y-m-d', strtotime('Tuesday')); $wednesday = date('Y-m-d', strtotime('Wednesday')); $thursday = date('Y-m-d', strtotime('Thursday')); $friday = date('Y-m-d', strtotime('Friday')); Today is 2012-08-01 (week 31) the Monday value I need should be 2012-07-30. How come strtotime('Monday') makes it next monday? Because date('Y-m-d') returns today's date i.e.., month of august. And you are converting monday to time . now that time is represented in terms of date(Y-m-d)

`strtotime` bug when using + 1 month from January

ε祈祈猫儿з 提交于 2019-12-05 16:55:37
I' m trying to make a ajax calendar with multiple tabs for a date range previously entered. But for example: I want get the next month, it prints march instead of february $start= "2013-01-31"; $current = date('n', strtotime("+1 month",$start)) //prints 3 I think thats occurs because february 2014 is 28 and add +31 like base from the start month but why? You're trying to add one month to the date 2013-01-31 . It should give 31th Feburary 2013, but since the date doesn't exist, it moves on to the next valid month (which is March). You can use the following work-around: $current = date('n',

php获取前一小时、前一天、三天前、前一个月、三个月前、前一年的时间

左心房为你撑大大i 提交于 2019-12-05 16:31:13
php获取前一个小时的时间: $mtime= date("Y-m-d H:i:s", strtotime("-1 hour")); php获取前一天的时间: $mtime= date("Y-m-d H:i:s", strtotime("-1 day")); php获取三天前的时间: $mtime= date("Y-m-d H:i:s", strtotime("-3 day")); php获取前一个月的时间: $mtime= date("Y-m-d H:i:s", strtotime("-1 month")); php获取三个月前的时间: $mtime= date("Y-m-d H:i:s", strtotime("-3 month")); php获取前一年的时间: $mtime= date("Y-m-d H:i:s", strtotime("-1 year")); 来源: https://www.cnblogs.com/pcx105/p/11933345.html

Strange behavior of Date Function

穿精又带淫゛_ 提交于 2019-12-05 11:51:27
I encountered with this question today on StackOverflow but didn't get answer. My question is echo date('Y-m-d',strtotime('2012-september-09')); // output - 2012-09-01 echo date('Y-m-d',strtotime('09-september-2012')); // output - 2012-09-09 Codepad I am confused that why the first format don't produce correct answer. Any Help? From the manual : if the separator is a slash (/), then the American m/d/y is assumed; whereas if the separator is a dash (-) or a dot (.), then the European d-m-y format is assumed . This is not behavior of the date function but of the strtotime . strtotime can handle

PHP Date使用

早过忘川 提交于 2019-12-05 09:11:34
若当前时间戳为$timeStamp=1467894352,对应的时间为2016年7月7日20点42分 如何获得本月第一天零点的时间戳? date('Y-m-01 00:00',$timeStamp); 类似的,可以获得本月任何一天的任何一点时间。或者本年的。或者今日的。或者该小时内的。等等…… +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 如何获得两天后这个时间的时间戳 $timeStr=date('Y-m-d hh:ii',$timeStamp); strtotime("$timeStr + 2day"); 类似的,可以获得两天前(-2day)。两个月前(-2month)。两年前(-2year)。加也行。 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 如何获得某个时间戳是周几 $week = date("w", strtotime($firstday)); $week的值为0~6 ,表示周日~周六 date()第一个参数还有很多可选值,会在本文最下放一一列出 +++++++++++++++++