PHP日期和时间函数。 中的 idate()

首页 / PHP入门教程 / PHP日期和时间函数。 中的 idate()

idate() - 语法

int idate ( string $format [, int $timestamp] );

它使用给定的整数时间戳返回根据给定格式字符串格式化的数字,如果没有给定时间戳,则返回当前本地时间。换句话说,时间戳是可选的,默认为time()的值。

Sr.No Parameter & Description
1

format(必需)

它指定如何返回输出-

  • B - Swatch Beat/Internet Time
  • d - Day of the month
  • h - Hour (12 hour format)
  • H - Hour (24 hour format)
  • i - Minutes
  • I - returns 1 if DST (daylight saving time) is activated, 0 otherwise
  • L - returns 1 for leap year, 0 otherwise
  • m - Month number
  • s - Seconds
  • t - Days in current month
  • U - Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
  • w - Day of the week (Sunday=0)
  • W - ISO-8601 week number of year (week starts on Monday)
  • y - Year (1 or 2 digits)
  • Y - Year (4 digits)
  • z - Day of the year
  • Z - Timezone offset in seconds
2

timestamp(可选)

无涯教程网

这是一个整数Unix时间戳,如果没有给定时间戳,则默认为当前本地时间。换句话说,它默认为time()的值。

链接:https://www.learnfk.comhttps://www.learnfk.com/php/php-function-idate.html

来源:LearnFk无涯教程网

idate() - 返回值

始终返回一个整数,并且由于它们不能以“ 0”开头,因此idate()返回的位数可能少于您的预期。

idate() - 示例

<?php
   $timestamp=strtotime('1st January 2014');
   
   echo idate('y', $timestamp);
   echo"\n";
   echo idate('t', $timestamp);
?>

这将产生以下输出-

14
31

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

许式伟的架构课 -〔许式伟〕

Flutter核心技术与实战 -〔陈航〕

编辑训练营 -〔总编室〕

Kafka核心源码解读 -〔胡夕〕

Linux内核技术实战课 -〔邵亚方〕

物联网开发实战 -〔郭朝斌〕

A/B测试从0到1 -〔张博伟〕

成为AI产品经理 -〔刘海丰〕

Redis源码剖析与实战 -〔蒋德钧〕

好记忆不如烂笔头。留下您的足迹吧 :)