PHP日期函数date格式化UNIX时间的方法

作者:work24 时间:2024-06-05 09:47:14 

本文实例讲述了PHP日期函数date格式化UNIX时间的方法。分享给大家供大家参考。具体分析如下:

日期函数可以根据指定的格式将一个unix时间格式化成想要的文本输出

使用到函数语法如下


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";
?>

输出结果如下


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程序设计有所帮助。

标签:PHP,日期,函数,date
0
投稿

猜你喜欢

  • javascript 移动鼠标得到单元格所在table表中的rowIndex位置[兼容ie,firefox] <font color=red>原创</font>

    2024-04-18 09:50:31
  • Python多线程、异步+多进程爬虫实现代码

    2023-07-29 03:28:42
  • jupyter notebook实现显示行号

    2022-11-20 03:51:40
  • python调用系统ffmpeg实现视频截图、http发送

    2021-05-20 13:18:53
  • 最简洁的多重查询的解决方案

    2008-03-02 15:51:00
  • mysql如何分组统计并求出百分比

    2024-01-22 02:07:51
  • python 实现logging动态变更输出日志文件名

    2023-10-26 06:40:27
  • Pytorch to(device)用法

    2022-05-04 22:57:19
  • tensorflow学习笔记之简单的神经网络训练和测试

    2021-02-18 20:28:14
  • python渗透测试linux密码激活的示例

    2023-06-25 16:57:41
  • Python同步遍历多个列表的示例

    2023-08-08 00:20:10
  • Python pyinotify模块实现对文档的实时监控功能方法

    2023-04-15 08:13:52
  • 将表数据生成SQL脚本的存储过程和工具

    2009-01-08 15:24:00
  • Python基于locals返回作用域字典

    2021-05-17 22:02:43
  • Mysql 5.7 新特性之 json 类型的增删改查操作和用法

    2024-01-24 23:45:53
  • jQuery 表单验证插件formValidation实现个性化错误提示

    2023-07-02 05:31:26
  • Python+Tensorflow+CNN实现车牌识别的示例代码

    2021-06-30 08:44:05
  • JavaScript for: i++ vs i–

    2010-06-24 21:42:00
  • 设计和企业文化

    2009-03-28 10:35:00
  • php版淘宝网查询商品接口代码示例

    2023-11-14 12:01:54
  • asp之家 网络编程 m.aspxhome.com