Definition and Usage

The date() function formats a local time/date.

Syntaxdate(format,timestamp)
ParameterDescriptionformat Required. Specifies how to return the result:

  • d - The day of the month (from 01 to 31)
  • D - A textual representation of a day (three letters)
  • j - The day of the month without leading zeros (1 to 31)
  • l (lowercase 'L') - A full textual representation of a day
  • N - The ISO-8601 numeric representation of a day (1 for Monday through 7 for Sunday)
  • S - The English ordinal suffix for the day of the month (2 characters st, nd, rd or th. Works well with j)
  • w - A numeric representation of the day (0 for Sunday through 6 for Saturday)
  • z - The day of the year (from 0 through 365)
  • W - The ISO-8601 week number of year (weeks starting on Monday)
  • F - A full textual representation of a month (January through December)
  • m - A numeric representation of a month (from 01 to 12)
  • M - A short textual representation of a month (three letters)
  • n - A numeric representation of a month, without leading zeros (1 to 12)
  • t - The number of days in the given month
  • L - Whether it's a leap year (1 if it is a leap year, 0 otherwise)
  • o - The ISO-8601 year number
  • Y - A four digit representation of a year
  • y - A two digit representation of a year
  • a - Lowercase am or pm
  • A - Uppercase AM or PM
  • B - Swatch Internet time (000 to 999)
  • g - 12-hour format of an hour (1 to 12)
  • G - 24-hour format of an hour (0 to 23)
  • h - 12-hour format of an hour (01 to 12)
  • H - 24-hour format of an hour (00 to 23)
  • i - Minutes with leading zeros (00 to 59)
  • s - Seconds, with leading zeros (00 to 59)
  • e - The timezone identifier (Examples: UTC, Atlantic/Azores)
  • I (capital i) - Whether the date is in daylights savings time (1 if Daylight Savings Time, 0 otherwise)
  • O - Difference to Greenwich time (GMT) in hours (Example: +0100)
  • T - Timezone setting of the PHP machine (Examples: EST, MDT)
  • Z - Timezone offset in seconds. The offset west of UTC is negative, and the offset east of UTC is positive (-43200 to 43200)
  • c - The ISO-8601 date (e.g. 2004-02-12T15:19:21+00:00)
  • r - The RFC 2822 formatted date (e.g. Thu, 21 Dec 2000 16:01:07 +0200)
  • U - The seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)

timestampOptional.

example:

function TtoDatetime($text){
        $myDatetimeStr=Date('Y',strtotime($text))."-".Date('m',strtotime($text))."-".Date('d',strtotime($text))." ".Date('H',strtotime($text)).":".Date('i',strtotime($text)).":".Date('s',strtotime($text));
        return $myDatetimeStr;
       }

echo $text;

echo TtoDatetime($text);

result:

"01/07/2012 13:44",2012-01-07 13:44:00

php中DateTime的format格式以及 TtoDatetime函数的更多相关文章

  1. sql查询中datetime显示的格式为yyyy-DD-mm

    datetime数据库中保存的形式为2008/9/29 星期一 上午 12:00:00,希望界面显示2008-09-29,则可以用到以下sql语句. ),kgrq, ),),jhjgrq, ),'/' ...

  2. 解决Asp.net Mvc返回JsonResult中DateTime类型数据格式的问题

    问题背景: 在使用asp.net mvc 结合jquery esayui做一个系统,但是在使用使用this.json方法直接返回一个json对象,在列表中显示时发现datetime类型的数据在转为字符 ...

  3. RMAN备份FORMAT格式中%的含义

    使用格式串先看例子:Configure channel 1 device type disk format 'd:/backup/orcl/backup_%U';在configure 命令中经常使用格 ...

  4. C# WebAPI中DateTime类型字段在使用微软自带的方法转json格式后默认含T的解决办法

    原文:C# WebAPI中DateTime类型字段在使用微软自带的方法转json格式后默认含T的解决办法 本人新手,在.Net中写WebAPI的时候,当接口返回的json数据含有日期时间类型的字段时, ...

  5. python中datetime模块

    Python提供了多个内置模块用于操作日期时间,像calendar,time,datetime.time模块我在之前的文章已经有所介绍,它提供 的接口与C标准库time.h基本一致.相比于time模块 ...

  6. python中 datetime模块的详解(转载)

    Python提供了多个内置模块用于操作日期时间,像calendar,time,datetime.time模块我在之前的文章已经有所介绍,它提供 的接口与C标准库time.h基本一致.相比于time模块 ...

  7. Python中datetime库的用法

    datetime模块用于是date和time模块的合集,datetime有两个常量,MAXYEAR和MINYEAR,分别是9999和1. datetime模块定义了5个类,分别是 1.datetime ...

  8. SQL中CONVERT日期不同格式的转换用法

    SQL中CONVERT日期不同格式的转换用法 格式: CONVERT(data_type,expression[,style]) 说明:此样式一般在时间类型(datetime,smalldatetim ...

  9. String.Format格式说明——复制于DotNet笔记

    String.Format格式说明   C#格式化数值结果表 字符 说明 示例 输出 C 货币 string.Format("{0:C3}", 2) $2.000 D 十进制 st ...

随机推荐

  1. UVALive 2145 Lost in Space(暴力)

    题目并不难,就是暴力,需要注意一下输出形式和精度. #include<iostream> #include<cstdio> #include<cmath> usin ...

  2. cocos2d-js 帧序列动画

    1.resource.js var res = { playerWalk_plist:"res/playerWalk.plist", playerWalk_png:"re ...

  3. POJ 2289 Jamie's Contact Groups

    二分答案+网络最大流 #include<cstdio> #include<cstring> #include<cmath> #include<vector&g ...

  4. 手机号码抽奖系统(JS)

    <html><head><title>手机号码抽奖</title><meta http-equiv="Content-Type" ...

  5. 彻底搞明白find命令的-mtime参数的含义【转载】

    转自: 彻底搞明白find命令的-mtime参数的含义-goolen-ITPUB博客http://blog.itpub.net/23249684/viewspace-1156932/ 以前一直没有弄明 ...

  6. POJ2096 概率dp 入门

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=118282#problem/B 挺好的一个题目: 不过刚开始嘛,看别人题解长知识.这个人写 ...

  7. TIdTCPClient 详解

    转发地址:http://blog.csdn.net/cowcga/article/details/6198382 关于TIdTCPClient的几种方法 收藏 其实Indy比较简单,但是可以提供的方法 ...

  8. Oracle教程-查询(二)

    emp 雇员表字段名称   数据类型       是否为空   备注--------   -----------   --------   --------EMPNO    NUMBER(4)     ...

  9. 基于Annotation与SpringAOP的缓存简单解决方案

    前言: 由于项目的原因,需要对项目中大量访问多修改少的数据进行缓存并管理,为达到开发过程中通过Annotation简单的配置既可以完成对缓存的设置与更新的需求,故而设计的该简易的解决方案. 涉及技术: ...

  10. [iOS]C语言技术视频-14-指针变量高级用法(函数指针)

    下载地址: 链接: http://pan.baidu.com/s/1ykyg2 密码: fg5t