zoukankan      html  css  js  c++  java
  • php中的日期和时间

    1、checkdate函数验证日期的正确性

         程序开发过程中,在需要设计填写日期和时间的模块中,

         有时会因为录入失误而产生错误。

         为了避免这些类的问题出现,在设计时就要对日期进行检验,

         就是利用checkdate函数。

         bool checkdata(int month,int day,int year);

         如果检验有效,返回true,否则返回false。

        month的有效值在1-12,day在给定的月之内,包括闰年,

        year的值在1-32767之间。

    2、date()函数将服务器的时间格式化

        string date(string format,int timestamp);

        参数format为显示格式,

        "Y"四位数字完整表示年份,

     "y"两位数字表示年份,

        "M"三个字母表示月份,

        "m"数字表示月份,

        "D"星期中的第几天,

        "d"月份中的第几天,

        "H"24小时格式,

        "h"12小时格式,

        "I"判断是否为夏令时,

        "i"分钟数,

        "s"秒数。

        参数timestamp为时间戳(可选,默认是time()),

        如果没有给出时间戳则使用本地当前时间。

    3、getdate获得时间及日期信息

      该函数返回值为一个数组,其中包括指定的日期和时间信息。

    如果没有给出时间戳,则输出的是本地当前的日期和时间。

    array getdate(int timestamp);

    4、time获取目前时间的UNIX时间戳

       int time();

  • 相关阅读:
    hdu 2132 An easy problem
    ACM暑假培训宣讲稿
    hdu Lovekey(水题)
    windows 下c++编译
    semantic
    could not open XXX permission denied
    sv_target_output dx11
    hlsl 的tex函数
    effect state dx11
    cg 到hlsl的转换
  • 原文地址:https://www.cnblogs.com/guoyinglichong/p/7087055.html
Copyright © 2011-2022 走看看