strtotime

根据周日获取这周的周日到周六的日期(周日为这周的第一天)

风流意气都作罢 提交于 2019-12-02 05:18:14
//获取相应周的开始时间(星期日)到(周六) function getWeekDate($year,$mon,$day){ $date1=$year.'-'.$mon.'-'.$day; $sun=$date1; $mon=date('Y-m-d',strtotime("$date1 +1 day")); $tues=date('Y-m-d',strtotime("$date1 +2 day")); $wed=date('Y-m-d',strtotime("$date1 +3 day")); $thurs=date('Y-m-d',strtotime("$date1 +4 day")); $fri=date('Y-m-d',strtotime("$date1 +5 day")); $sat=date('Y-m-d',strtotime("$date1 +6 day")); return array($sun,$mon,$tues,$wed,$thurs,$fri,$sat); } 代码的参数为年月日三项,可以更改成一个参数(周日的日期) 来源: https://www.cnblogs.com/leaf-blog/p/11731570.html

获取两个日期之间的全部的日期数据(包括两个日期)

牧云@^-^@ 提交于 2019-12-02 05:18:10
function getMonDate($start,$end){ $monArr=array(); $dt_start = strtotime($start); $dt_end = strtotime($end); while ($dt_start<=$dt_end){ $monArr[]=date('Y-m-d',$dt_start); $dt_start = strtotime('+1 day',$dt_start); } return $monArr; } 来源: https://www.cnblogs.com/leaf-blog/p/11731571.html

PHP 各种时间处理

℡╲_俬逩灬. 提交于 2019-12-02 04:54:22
时间参数详解   a - "am" 或是 "pm"    A - "AM" 或是 "PM"    d - 几日,二位数字,若不足二位则前面补零; 如: "01" 至 "31"    D - 星期几,三个英文字母; 如: "Fri"    F - 月份,英文全名; 如: "January"    h - 12 小时制的小时; 如: "01" 至 "12"    H - 24 小时制的小时; 如: "00" 至 "23"    g - 12 小时制的小时,不足二位不补零; 如: "1" 至 12"    G - 24 小时制的小时,不足二位不补零; 如: "0" 至 "23"    i - 分钟; 如: "00" 至 "59"    j - 几日,二位数字,若不足二位不补零; 如: "1" 至 "31"    l - 星期几,英文全名; 如: "Friday"    m - 月份,二位数字,若不足二位则在前面补零; 如: "01" 至 "12"    n - 月份,二位数字,若不足二位则不补零; 如: "1" 至 "12"    M - 月份,三个英文字母; 如: "Jan"    s - 秒; 如: "00" 至 "59"    S - 字尾加英文序数,二个英文字母; 如: "th","nd"    t - 指定月份的天数; 如: "28" 至 "31"    U - 总秒数   

Can anyone explain why strtotime('cast') returns a value?

旧街凉风 提交于 2019-12-01 20:43:56
Not really an issue (although it is conflicting with an if() statement we have), but when you type in strtotime('cast'), it returns an actual value that defaults to today's date. I was just wondering if anyone knew what significance the word cast has when it comes to time functions Thanks! It maps to the timezone offset for "Australia/Adelaide" . Example: echo date('Y-m-d H:i:s'), "\n", date('Y-m-d H:i:s', strtotime("cast")), "\n", date('Y-m-d H:i:s', strtotime("Australia/Adelaide")); Prints: 2016-08-25 10:48:44 2016-08-25 01:18:44 2016-08-25 01:18:44 来源: https://stackoverflow.com/questions

PHP strtotime returning false for dates less than 1900

℡╲_俬逩灬. 提交于 2019-12-01 19:11:18
问题 I know this question is very popular Asked here PHP: strtotime is returning false for a future date? and here How can I work with dates before 1900 in PHP? Could you please confirm my choices: Upgrade to a 64bit architecture Replace the strtotime calls by DateTime + DateInterval We can't call DateTime->getTimestamp but we can use DateInterval to calculate the diff Do I have any other options? Unfortunately, I can't pick option 2 because I am relying on ORM (Propel) + a lot of legacy code

PHP strtotime() “first monday february” returns second monday if february 1st is a monday

巧了我就是萌 提交于 2019-12-01 16:50:22
I'm working on a PHP function which calculates holidays: function holidays($country = 1, $timespan_start = 0, $timespan_end = 0) The holidays are returned as timestamps in an array. Since I have to calculate dates like the first Monday of February, I tried strtotime("first monday february $year") and I've discovered that this does not work for 2010, since 02/01/2010 is a Monday - I get February 8th instead. This bug is actually mentioned in the change log: In PHP 5 prior to 5.2.7, requesting a given occurrence of a given weekday in a month where that weekday was the first day of the month

接口按月 按日查询数据

血红的双手。 提交于 2019-12-01 12:40:11
环境php本地写接口 1.PHP工具箱配置好相应的本地域名 2.下载一个客户端postman   1.按日查询.接口传过来 $page $uid $time /* * 2019.10.15 *订单统计 * & 骑手的id * orderstatistics 按日查询 * */public function orderstatistics(){ $res = []; $param = input(''); $page = input('page'); $uid = $param['uid'];//骑手的id $time = $param['time'];//查询的时间 $data = $this-> order -> statistics($uid,$time,$page);//获取订单的列表 foreach ($data['data'] as $k=>&$v){ // status = 1:已接单 2:取货中 3:已取消 4:配送中 5:已完成 6:已评价', switch ($v['status']){ case 1: $v['status_name'] = '已接单';break; case 2: $v['status_name'] = '取货中';break; case 3: $v['status_name'] = '已取消';break; case 4: $v[

Convert MMDDYYYY to date for PHP

百般思念 提交于 2019-12-01 10:26:21
I have a string with a date which is in this format MMDDYYYY (ie. 01132012, 01142012 etc.) I need to do something on a page, if that string is 14 days or less from the current date. ie. Today is 01132012, so any strings with 12312011 or a less date are going to be showing something on a page. Can anyone help with this? I've tried echo date("d/m/Y", strtotime('01142012')); But to no avail. You can use the DateTime class of PHP <? // current date $now = new DateTime(); //your date $date = DateTime::createFromFormat('mdY', '01142012'); // calculate difference $diff = $now->diff($date); ... //

按添加时间查询今天,本周,本月,本年的数据

别说谁变了你拦得住时间么 提交于 2019-12-01 10:02:09
今天 $mapday = array(); $today = strtotime(date('Y-m-d', time())); //当前时间 $start_today = $today; $end_today = $today + 86400; //,获取明天,一天是86400(时间戳) $mapday['create_time'] = array( //数据表字段create_time进行条件判断 array('egt', $start_today), array('lt', $end_today), ); 本周 //查询周日至周六数据记录 $mapweek['create_time'] = array( array('egt', strtotime(date('Y-m-d', time()).'-'.date('w', time()).' day')), array('lt', strtotime(date('Y-m-d', time()).'+1 week -'.date('w', time()).' day')),//一周内 ); //查询周一至周日记录 $mapweek['create_time'] = array( array('egt', strtotime(date('Y-m-d', time()).'+1 day -'.date('w', time()).'

get strtotime of specific time in php

橙三吉。 提交于 2019-12-01 06:29:25
I want to get the timestamp of a day/time for eg 17/12/2014 8pm Currently I am doing $curtime = strtotime(date("Y-m-d H:i:s")); which is giving me the current timestamp but I need to be of 8pm. Any help is highly appreciated. Thanks in advance. If you're trying to get a timestamp of today at 8pm, it's actually much more simple than using date since you can use relative times in a strtotime : $curtime = strtotime('today 8pm'); If you test this with date : echo date('Y-m-d H:i:s', $curtime); // Returns 2014-12-17 20:00:00 Here's a whole writeup on relative date formats that explains how you can