PHP获取某年某月开始和结束的时间戳

薛定谔的盒子猫
• 阅读 1364
/**
 * 月份开始结束时间戳
 * $y 年
 * $m 月
 */
function mFristAndLast($y = "", $m = "")
{
    if ($y == "") $y = date("Y");
    if ($m == "") $m = date("m");
    $m = sprintf("%02d", intval($m));
    $y = str_pad(intval($y), 4, "0", STR_PAD_RIGHT);

    $m > 12 || $m < 1 ? $m = 1 : $m = $m;
    $firstday = strtotime($y . $m . "01000000");
    $firstdaystr = date("Y-m-01", $firstday);
    $lastday = strtotime(date('Y-m-d 23:59:59', strtotime("$firstdaystr +1 month -1 day")));

    return array(
        "firstday" => $firstday,
        "lastday" => $lastday
    );
}
点赞
收藏
评论区
推荐文章
Wesley13 Wesley13
2年前
mysql时间日期总结
下面对mysql时间和日期处理做下总结1.获取当前日期时间函数nowpythontime.strftime("%Y%y%d%H:%M:%S")selectnow();|2013112309:58:01|2.获取当前日期函数cur
Wesley13 Wesley13
2年前
mysql简单常用语句汇总
1\.常用函数uuid和时间戳SELECTUUID(),UNIX_TIMESTAMP();将时间戳转为日期格式FROM_UNIXTIME(mw.created_at,'%Y%m%d%H:%i:%s')设置参数select@m_no:max(m_no)fromvc_m;set@m
Stella981 Stella981
2年前
Python获取并输出当前日期时间
1234567取得当前时间戳importtimeprinttime.time()格式化时间戳为标准格式printtime.strftime('%Y.%m.%d',time.localtime(time.time()))获取30天前的时间(通过加减秒数来获取现在或者未来某个时间点)printtime.strftime('%Y.
Wesley13 Wesley13
2年前
mysql相似于oracle的to_char() to_date()方法
mysql日期和字符相互转换方法date\_format(date,'%Y%m%d')  oracle中的to\_char();str\_to\_date(date,'%Y%m%d')  oracle中的to\_date();%Y:代表4位的年份%y:代表2为的年份
Stella981 Stella981
2年前
Python之time模块的时间戳、时间字符串格式化与转换
Python处理时间和时间戳的内置模块就有time,和datetime两个,本文先说time模块。关于时间戳的几个概念时间戳,根据1970年1月1日00:00:00开始按秒计算的偏移量。时间元组(struct_time),包含9个元素。 time.struct_time(tm_y
Wesley13 Wesley13
2年前
mysql 导入hive的脚本
!/bin/bashtanj20170911DATE\date%Y%m%d\TIME\date%H:%M:%S\echo"$DATE$TIMEstart"if \!n"$1"\;then  
Wesley13 Wesley13
2年前
mysql timestamp
 select from\_unixtime(m.createdAt, '%Y%m%d %H:%i:%s') from kfrobotaidlog m;select m.customeruid, from\_unixtime(m.createtime, '%Y%m%d %H:%i:%s') as \datetime\, m.kfui
Stella981 Stella981
2年前
Python time模块 返回格式化时间
常用命令  strftimetime.strftime("%Y%m%d%H:%M:%S",formattime)第二个参数为可选参数,不填第二个参数则返回格式化后的当前时间日期201812112:00:00time.strftime('%H:%M:%S')返回当前时间的时分秒time.strftim
Wesley13 Wesley13
2年前
mysql统计
时间转任意格式DATE_FORMATselectDATE_FORMAT(NOW(),'%m%d%Y');unix_timestamp时间转时间戳selectunix_timestamp(now());from_unixtime时间戳转时间
Wesley13 Wesley13
2年前
常用模块之
importdatetimeimporttimeprint(time.strftime('%y/%m/%d%X'))输出结果:18/06/0520:40:46print(time.strftime('%Y/%m/%d%X'))输出结果:2018/06/
薛定谔的盒子猫
薛定谔的盒子猫
Lv1
男 · 四川智慧谦益科技有限公司 · 技术总监
暮雨不来春不去,花满地月朦胧。
文章
7
粉丝
2
获赞
2