PHP日期函數(shù)date格式化UNIX時(shí)間的方法
來源:易賢網(wǎng) 閱讀:819 次 日期:2015-03-23 14:43:46
溫馨提示:易賢網(wǎng)小編為您整理了“PHP日期函數(shù)date格式化UNIX時(shí)間的方法”,方便廣大網(wǎng)友查閱!

這篇文章主要介紹了PHP日期函數(shù)date格式化UNIX時(shí)間的方法,實(shí)例分析了php中date函數(shù)的使用技巧,需要的朋友可以參考下

本文實(shí)例講述了PHP日期函數(shù)date格式化UNIX時(shí)間的方法。分享給大家供大家參考。具體分析如下:

日期函數(shù)可以根據(jù)指定的格式將一個(gè)unix時(shí)間格式化成想要的文本輸出

使用到函數(shù)語法如下

string date (string $Format);

string date (string $Format, int $Time);

下面是演示代碼

<?php

echo "When this page was loaded,\n";

echo 'It was then ', date ('r'), "\n";

echo 'The currend date was ', date ('F j, Y'), "\n";

echo 'The currend date was ', date ('M j, Y'), "\n";

echo 'The currend date was ', date ('m/d/y'), "\n";

echo 'The currend date was the ', date ('jS \o\f M, Y'), "\n";

echo 'The currend time was ', date ('g:i:s A T'), "\n";

echo 'The currend time was ', date ('H:i:s O'), "\n";

echo date ('Y');

date ('L')?(print ' is'):(print ' is not');

echo " a leap year\n";

echo time ('U'), " seconds had elapsed since January 1, 1970.\n";

?>

輸出結(jié)果如下

It was then Sat, 26 Dec 2009 07:09:51 +0000

The currend date was December 26, 2009

The currend date was Dec 26, 2009

The currend date was 12/26/09

The currend date was the 26th of Dec, 2009

The currend time was 7:09:51 AM GMT

The currend time was 07:09:51 +0000

2009 is not a leap year

1261811391 seconds had elapsed since January 1, 1970.

希望本文所述對大家的php程序設(shè)計(jì)有所幫助。

更多信息請查看IT技術(shù)專欄

更多信息請查看網(wǎng)絡(luò)編程
易賢網(wǎng)手機(jī)網(wǎng)站地址:PHP日期函數(shù)date格式化UNIX時(shí)間的方法
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

2025國考·省考課程試聽報(bào)名

  • 報(bào)班類型
  • 姓名
  • 手機(jī)號
  • 驗(yàn)證碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機(jī)站點(diǎn) | 投訴建議
工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
云南網(wǎng)警備案專用圖標(biāo)
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報(bào)警專用圖標(biāo)