PHP调用时间格式的参数详解

9月 17, 2008

1、调用语法
使用函式date() 实现获取当前的时间格式,例如:<?php echo $showtime=date(“Y-m-d H:i:s”);?>
2、时间格式参数设定
上面语法中”Y-m-d H:i:s”,显示的格式为: 年-月-日 小时:分钟:秒
这样看来,我们只要获取对应的相关时间参数就可以替换出自己想要的时间格式了!以下是网上找来的具体参数详解:

  • a – “am” 或是 “pm”
  • A – “AM” 或是 “PM”
  • d – 几日,二位数字,若不足二位则前面补零; 如: “01” 至 “31”
  • D – 星期几,三个英文字母; 如: “Fri”
  • F – 月份,英文全名; 如: “January”
  • h – 12 小时制的小时; 如: “01” 至 “12”
  • H – 24 小时制的小时; 如: “00” 至 “23”
  • g – 12 小时制的小时,不足二位不补零; 如: “1” 至 12″
  • G – 24 小时制的小时,不足二位不补零; 如: “0” 至 “23”
  • i – 分钟; 如: “00” 至 “59”
  • j – 几日,二位数字,若不足二位不补零; 如: “1” 至 “31”
  • l – 星期几,英文全名; 如: “Friday”
  • m – 月份,二位数字,若不足二位则在前面补零; 如: “01” 至 “12”
  • n – 月份,二位数字,若不足二位则不补零; 如: “1” 至 “12”
  • M – 月份,三个英文字母; 如: “Jan”
  • s – 秒; 如: “00” 至 “59”
  • S – 字尾加英文序数,二个英文字母; 如: “th”,”nd”
  • t – 指定月份的天数; 如: “28” 至 “31”
  • U – 总秒数
  • w – 数字型的星期几,如: “0” (星期日) 至 “6” (星期六)
  • Y – 年,四位数字; 如: “1999”
  • y – 年,二位数字; 如: “99”
  • z – 一年中的第几天; 如: “0” 至 “365”
, , , / 1 回話 / 11,032 views

一条评论

  1. google 2012年11月2日 下午1:56 回复

    Needed to post you that very small remark to be able to say thanks yet again over the striking opinions you have shown above. This is certainly particularly open-handed with you to allow pub哈哈哈cly exactly what most of us could have distributed for an e-book to help make some money for themselves, most importantly considering the fact that you could have tried it if you decided. The smart ideas as well acted to provide a fantastic way to fully grasp the rest have the identical dream much 哈哈哈ke my very own to understand more and more regarding this matter. Certainly there are mil哈哈哈ons of more pleasant occasions up front for those who look over your site.

  2. google 2012年11月2日 下午1:56 回复

    Needed to post you that very small remark to be able to say thanks yet again over the striking opinions you have shown above. This is certainly particularly open-handed with you to allow pub哈哈哈cly exactly what most of us could have distributed for an e-book to help make some money for themselves, most importantly considering the fact that you could have tried it if you decided. The smart ideas as well acted to provide a fantastic way to fully grasp the rest have the identical dream much 哈哈哈ke my very own to understand more and more regarding this matter. Certainly there are mil哈哈哈ons of more pleasant occasions up front for those who look over your site.

发表评论

邮箱地址不会被公开。 必填项已用*标注

Ɣ