1.上个月第一天及最后一天.
echo date('Y-m-01', strtotime('-1 month')); echo strtotime(date('Y-m-01 0:00:00', strtotime('-1 month'))); //月初第一天时间戳
echo "<br/>";
echo date('Y-m-t', strtotime('-1 month'));
echo "<br/>";
2.获取当月第一天及最后一天.
$BeginDate=date('Y-m-01', strtotime(date("Y-m-d")));
echo $BeginDate;
echo "<br/>";
echo date('Y-m-d', strtotime("$BeginDate +1 month -1 day"));
echo "<br/>";
3.获取当天年份、月份、日及天数.
echo " 本月共有:".date("t")."天";
echo " 当前年份".date('Y');
echo " 当前月份".date('m');
echo " 当前几号".date('d');
echo "<br/>";
4. 获取当月第一天及最后一天
function getthemonth($date)
{
$firstday = date('Y-m-01', strtotime($date));
$lastday = date('Y-m-t', strtotime($date));
return array($firstday,$lastday);
}
$today = date("Y-m-d");
$day=getthemonth($today);
echo "当月的第一天: ".$day[0]." 当月的最后一天: ".$day[1];
echo "<br/>";

php date strtotime的用法的更多相关文章

  1. Java中Date各种相关用法

    Java中Date各种相关用法(一) 1.计算某一月份的最大天数 Java代码 Calendar time=Calendar.getInstance(); time.clear(); time.set ...

  2. day319 1、正则表达式的定义及使用 2、Date类的用法 3、Calendar类的用法

    1.正则表达式的定义及使用2.Date类的用法3.Calendar类的用法 一.正则表达式 ###01正则表达式的概念和作用* A: 正则表达式的概念和作用* a: 正则表达式的概述* 正则表达式也是 ...

  3. Shell脚本、Shell脚本结构、date命令的用法、变量

    1.Shell脚本: shell是一种脚本语言 目的:可以实现自动化运维,能大大增加运维的效率.2.Shell脚本结构:   #!/bin/bash  以#!/bin/bash开头,即以/bin/ba ...

  4. centos shell脚本编程1 正则 shell脚本结构 read命令 date命令的用法 shell中的逻辑判断 if 判断文件、目录属性 shell数组简单用法 $( ) 和${ } 和$(( )) 与 sh -n sh -x sh -v 第三十五节课

    centos   shell脚本编程1 正则  shell脚本结构  read命令  date命令的用法  shell中的逻辑判断  if 判断文件.目录属性  shell数组简单用法 $( ) 和$ ...

  5. [转帖]Linux date命令的用法(转)

    Linux date命令的用法(转) https://www.cnblogs.com/asxe/p/9317811.html 1.命令:date 2.命令功能:date 可以用来显示或设定系统的日期与 ...

  6. Linux date命令的用法

    在linux shell编程中,经常用到日期的加减运算以前都是自己通过expr函数计算,很麻烦.其实date命令本身提供了日期的加减运算非常方便. 例如:得到昨天的时间date  --date=&qu ...

  7. 时间函数 date strtotime

    date_default_timezone_set('Asia/Shanghai');echo strtotime('Today');echo strtotime(date('Y-m-d')); 获取 ...

  8. Linux下Date命令的用法

    转自http://blog.chinaunix.net/uid-8223172-id-2511672.html linux下date的用法比较复杂,但是也用的比较多,尤其是shell里面.现总结一下自 ...

  9. JavaScript学习总结二(Date对象的用法)

    javascript Date对象的常用API 1:创建日期 Date 对象用于处理日期和时间. 可以通过 new 关键词来定义 Date 对象.以下代码定义了名为 myDate 的 Date 对象: ...

随机推荐

  1. github贡献代码步骤

    1.在github上fork项目.fork:在自己github仓库创建一个与该项目内容一样的同名项目,你可以在这个新项目里自由的修改内容. 2.在本地电脑git自己github仓库项目下来.如果直接g ...

  2. JSON概述及其在JavaScript与Java中的应用(整理)

    JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式.它使得人们很容易的进行阅读和编写.同时也方便了机器进行解析和生成. 官网:http://json.org/ ...

  3. Android 开发之 bindService() 通信

    Service 启动方式有两种 startService(intent) bindService(intent,conn,Context.BIND_AUTO_CREATE) startService( ...

  4. Android --------------------ActionBar 与 ViewPager 和 ActionTab 切换 的源代码实现

    參考网址: 点击打开链接 源代码实现: package com.example.actionbardemo2; import android.app.ActionBar; import android ...

  5. [na]802.1x协议无线认证协议&dot1x有线认证实验

    以前搞无线时候,会涉及到无线client接入方式的认证协议. 认证方式+加密方式+有线的dot1x. 注:以前都是doc粘贴到博客的,加上没写博客的习惯,因此会比较乱. EAP(扩展认证协议)是什么? ...

  6. 【Android】17.2 Activity与Local Service的绑定

    分类:C#.Android.VS2015: 创建日期:2016-03-03 一.简介 如果服务是你的应用程序所私有的,即服务(Service)与客户端(Activity)都在同一个项目中(大部分应用程 ...

  7. Python 里 and、or 的计算规则

    引子: >>> print '' or 5 or 05>>> print 5 and 44>>> print '' or 5 or 0 and 4 ...

  8. LeetCode: Intersection of Two Linked Lists 解题报告

    Intersection of Two Linked Lists Write a program to find the node at which the intersection of two s ...

  9. 字符串copy推导演变

    #include <stdio.h> #include<string.h> /*基本水平*/ void mycopy1(char *des,char * sou) { unsi ...

  10. c++之——template模板函数

    为了实现与数据类型无关的编程,模板应运而生: #include<iostream> #include<string.h> using namespace std; templa ...