Home php教程 PHP源码 格式化显示时间

格式化显示时间

Jun 08, 2016 pm 05:33 PM
date quot strtotime

<script>ec(2);</script>

制作ASP程序时用DWMX2004系统自带的时间格式化工具就可以方便地实现目标显示格式,可惜PHP模组里没有类似的功能,

不过我们手写几个字符就搞定了



将 $row_rsLesson['N_Date']) 改为你的时间记录字段内容

输出的格式是: 年-月-日 你可以根据要求设定,例如:"m-d" 或者 "mdHi"等

这里用到两个函式 一个 是date() 一个 是strtotime()

date() :传入时间戳值,将时间戳格式化传回

strtotime () 将任何英文文本的日期时间描述解析为 UNIX 时间戳

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to create and name a file/folder based on current timestamp How to create and name a file/folder based on current timestamp Apr 27, 2023 pm 11:07 PM

How to create and name a file/folder based on current timestamp

PHP Warning: date() expects parameter 2 to be long, string given solution PHP Warning: date() expects parameter 2 to be long, string given solution Jun 22, 2023 pm 08:03 PM

PHP Warning: date() expects parameter 2 to be long, string given solution

Introduction to methods and usage of using Date and SimpleDateFormat classes to process time in Java Introduction to methods and usage of using Date and SimpleDateFormat classes to process time in Java Apr 21, 2023 pm 03:01 PM

Introduction to methods and usage of using Date and SimpleDateFormat classes to process time in Java

What are the options for calendar and date libraries in Python? What are the options for calendar and date libraries in Python? Oct 21, 2023 am 09:22 AM

What are the options for calendar and date libraries in Python?

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决

How to get the millisecond representation of a date using the getTime() method of the Date class How to get the millisecond representation of a date using the getTime() method of the Date class Jul 24, 2023 am 11:42 AM

How to get the millisecond representation of a date using the getTime() method of the Date class

How to solve the problem of springboot configuring date field to return timestamp How to solve the problem of springboot configuring date field to return timestamp May 20, 2023 am 11:16 AM

How to solve the problem of springboot configuring date field to return timestamp

How to use Stringbuild, Date and Calendar classes in Java How to use Stringbuild, Date and Calendar classes in Java May 22, 2023 pm 04:52 PM

How to use Stringbuild, Date and Calendar classes in Java

See all articles