1,转化为时间戳函数:strtotime()

本函数接受一个包含美国英语日期格式的字符串并尝试将其解析为Unix时间戳,其值相对于now参数给出的时间,如果没有提供此参数则使用系统当前时间。

<?php
/**
* Created by PhpStorm.
* User: 58
* Date: 2016/9/19
* Time: 15:56
*/
echo @strtotime("now");
echo '<br/>';
echo @strtotime("10 September 2015");
echo '<br/>';
echo @strtotime('+1 day');
echo '<br/>';
echo @strtotime('+1 week');
echo '<br/>';
echo @strtotime('+1 week 2 days 4 hours 2 seconds');
echo '<br/>';
echo @strtotime('next Thursday');
echo '<br/>';
echo @strtotime('last Monday');

注:如果给定的年份是两位数字的格式,则其值0-69表示2000-2069,70-100表示1970-2000。

2,将时间戳转化为日期格式,date('Y-m-d H:i:s',$str)

<?php
/**
* Created by PhpStorm.
* User: 58
* Date: 2016/9/19
* Time: 15:56
*/
$str = '1474274570';
echo date('Y-m-d H:i:s',$str);

PHP中日期函数的更多相关文章

  1. Hive中日期函数总结

    --Hive中日期函数总结: --1.时间戳函数 --日期转时间戳:从1970-01-01 00:00:00 UTC到指定时间的秒数 select unix_timestamp(); --获得当前时区 ...

  2. MySQL中日期函数的使用

    1. MySQL中日期函数的使用 1.1. 转DATETIME类型为Date类型 将add_time ::56转化为date类型 select * from product where Date(ad ...

  3. sql数据库中日期函数---2017-04-12

    一.SQLServer时间日期函数详解 1.  当前系统日期.时间 select getdate() 2. dateadd      在向指定日期加上一段时间的基础上,返回新的 datetime 值 ...

  4. mysql语句中日期函数和日期的加减运算

    一.秒数和时钟格式的互相转化 SEC_TO_TIME(seconds) 返回seconds参数,变换成小时.分钟和秒,值以'HH:MM:SS'或HHMMSS格式化,取决于函数是在一个字符串还是在数字. ...

  5. Android中日期函数Calendar的一些用法和注意事项

    1.月份获取时加1 Canlendar.MONTH + 1 因为使用的是罗马历,Calendar.MONTH返回的数值不是一年中月份的值,而是当前月份距离第一个月份的差值 如:当前月份为9月份,距离1 ...

  6. Javascript中日期函数的相关操作

    Date对象具有多种构造函数,下面简单列举如下: new Date() new Date(milliseconds) new Date(datestring) new Date(year, month ...

  7. Python 中日期函数

    导入日期库 datetime import datetime # 或者from datetime import datetime ,date 字符串转datetime

  8. Js日期函数Date格式化扩展

    prototype是向对象中添加属性和方法,返回对象类型原型的引用,例如对js中日期函数Date进行扩展: Date.prototype.Format = function (fmt) { var o ...

  9. MySQL中时间函数NOW()和SYSDATE()的区别

    mysql中日期函数还是比较常用的.主要有NOW()和SYSDATE()两种,虽然都表示当前时间,但使用上有一点点区别. NOW()取的是语句开始执行的时间,SYSDATE()取的是动态的实时时间. ...

随机推荐

  1. UDP接收数据

    http://blog.csdn.net/xingzheouc/article/details/49946191 http://blog.csdn.net/robertkun/article/deta ...

  2. [BAT]操作系统定时任务调用批处理忽略error继续运行的方法

    如下,通过forfiles删除7天以前生成的一些文件,当不存在满足搜索条件的文件时,就会报错:ERROR: No files found with the specified search crite ...

  3. OSGi 系列(一)之什么是 OSGi :Java 语言的动态模块系统

    OSGi 系列(一)之什么是 OSGi :Java 语言的动态模块系统 OSGi 的核心:模块化.动态.基于 OSGi 就可以模块化的开发 java 应用,模块化的部署 java 应用,还可以动态管理 ...

  4. jQuery获得元素位置offset()和position()的区别

    jQuery获得元素位置offset()和position()的区别 jQuery 中有两个获取元素位置的方法offset()和position(),这两个方法之间有什么异同 offset(): 获取 ...

  5. 内建类型,与用户自定义类型,返回值为const

    1对内建类型来说,按值返回的是否为const,是无关紧要的,因为编译器已经不让它成为一个坐直,因为它总是一个值,而不是一个变量(thing in c++ page192) 2当处理用户自定义的类型时, ...

  6. http mimetype为multipart/x-mixed-replace报文

    http://blog.csdn.net/gmstart/article/details/7064034 服务器推送(Server Push) 推送技术的基础思想是将浏览器主动查询信息改为服务器主动发 ...

  7. 2018.09.09 bzoj4403: 序列统计(Lucas定理)

    传送门 感觉单调不降序列什么的不好做啊. 于是我们序列中下标为i的元素的值加上i,这样就构成了一个单调递增的序列. 问题就变成了: 求出构造长度分别为1 ~ n且每个元素的值在l+1 ~ r+n之间的 ...

  8. 27. Green Building 绿色建筑

    27. Green Building 绿色建筑 ①When we think of green buildings,we tend to think of new ones-the kind of h ...

  9. 打包python为可执行文件时报错R6034解决方案

    R6034 指的是:”An application has made an attempt to load the C runtime library incorrectly. Please cont ...

  10. A标签中传递的中文参数到Servlet 后台request.getParameter()接收时出现中文乱码

    package util; import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletRequ ...