根据指定时间获取时间
来源:互联网 发布:mac怎样删除文件 编辑:程序博客网 时间:2024/06/02 15:57
当前年份:date('Y')当前月份:date('m')获取指定时间的时间戳:当前时间:time();指定时间: strtotime('2012-03-22')echo strtotime(date('Y-d-m')),输出结果:(结合date(),结果同上)(时间日期转换为时间戳)strtotime()还有个很强大的用法,参数可加入对于数字的操作、年月日周英文字符,示例如下:echo date('Y-m-d H:i:s',strtotime('+1 day')),输出结果:2012-03-23 23:30:33(会发现输出明天此时的时间)echo date('Y-m-d H:i:s',strtotime('-1 day')),输出结果:2012-03-21 23:30:33(昨天此时的时间)echo date('Y-m-d H:i:s',strtotime('+1 week')),输出结果:2012-03-29 23:30:33(下个星期此时的时间)echo date('Y-m-d H:i:s',strtotime('next Thursday')),输出结果:2012-03-29 00:00:00(下个星期四此时的时间)echo date('Y-m-d H:i:s',strtotime('last Thursday')),输出结果:2012-03-15 00:00:00(上个星期四此时的时间)等等,strtotime()方法可以通过英文文本的控制Unix时间戳的显示,而得到需要的时间日期格式。获取当前月的第一天function getCurMonthFirstDay($date) { return date('Y-m-01', strtotime($date));}获取当前月的最后一天function getCurMonthLastDay($date) { return date('Y-m-d', strtotime(date('Y-m-01', strtotime($date)) . ' +1 month -1 day'));}获取指定日期的下个月的第一天function getNextMonthFirstDay($date) { return date('Y-m-d', strtotime(date('Y-m-01', strtotime($date)) . ' +1 month'));}获取指定日期的下个月的最后一天function getNextMonthLastDay($date) { return date('Y-m-d', strtotime(date('Y-m-01', strtotime($date)) . ' +2 month -1 day'));}获取指定日期的上个月的第一天function getPrevMonthFirstDay($date) { return date('Y-m-d', strtotime(date('Y-m-01', strtotime($date)) . ' -1 month'));}获取指定日期的上个月的最后一天function getPrevMonthLastDay($date) { return date('Y-m-d', strtotime(date('Y-m-01', strtotime($date)) . ' -1 day'));}当前月的第一天
$month = time(); //当前时间$year_temp = strftime("%Y", $month); // 当前年 $month_temp = strftime("%m", $month); // 当前月$hour_temp = strftime("%H", $month); //当前小时$min_temp = strftime("%M", $month); //当前小时$sec_temp = strftime("%S", $month); //当前秒$first_day = strftime("%d %B %Y", mktime(0, 0, 0, $month_temp, 1, $year_temp));
//当前月的第一天
当前月的最后一天-------------下个月的前一天
$next_month = strtotime("+1 month"); //下个月$year_temp = strftime("%Y", $next_month);$month_temp = strftime("%m", $next_month);$hour_temp = strftime("%H", $next_month);$min_temp = strftime("%M", $next_month);$sec_temp = strftime("%S", $next_month);$last_day = strftime("%d %B %Y", mktime(0, 0, 0, $month_temp, 0, $year_temp));
//当前月的最后一天
- 根据指定时间获取时间
- 根据指定时间获取前一周的时间
- 根据本地/服务器时间获取指定时区时间 new Date指定时区时间
- js根据当前时间获取指定范围内的时间段日期
- 获取指定时间时间戳
- 获取指定时间
- Calendar获取指定时间
- 获取指定时间
- 根据固定时间格式获取时间
- 根据系统时间获取当前时间
- 根据秒数获取时间
- mysql 获取指定时间时间戳
- 获取指定日期时间的时间戳
- Date 获取当前时间和指定时间
- 获取指定时区的时间
- 获取指定时间的前一天
- php 获取指定格式时间
- 获取指定网站的时间
- VpnService
- 远程连接虚拟机,怎样将窗体模式转换为全屏模式???
- git 使用记录
- java 日志 自定义过滤
- linux 消息队列实例
- 根据指定时间获取时间
- 经典的面试问答(转自黑马培训营论坛)
- Patch文件的创建和使用
- HDOJ 5252 追星族
- touch触摸滑屏
- 西楚战队强势出手控股韩国知名品牌“蜜都”
- Android点击EditText文本框之外任何地方隐藏键盘的解决办法
- JAVA -- 关键字 abstract、static、final、native、synchronized
- iOS KVC和KVO