php 今天日期_今天使用PHP的日期

php 今天日期

Server-side PHP scripting gives web developers the ability to add features that change to their websites. They can use it to generate dynamic page content, collect form data, send and receive cookies and display the current date. This code only works on pages where PHP is enabled, which means the code displays a date on pages that end in .php. You can name your ​HTML page with a .php extension or other extensions set up on your server to run PHP.

服务器端PHP脚本使Web开发人员能够添加更改其网站的功能。 他们可以使用它来生成动态页面内容,收集表单数据,发送和接收Cookie以及显示当前日期。 此代码仅在启用PHP的页面上有效,这意味着该代码在以.php结尾的页面上显示日期。 你能说出你的HTML页面用PHP扩展或设置其他扩展你的服务器来运行PHP上。

今天日期的示例PHP代码 ( Example PHP Code for Today's Date )

Using PHP, you can display the current date on your website using a single line of PHP code.

使用PHP,您可以使用一行PHP代码在您的网站上显示当前日期。

这是如何运作的 ( Here's How It Works )

  1. Inside an HTML file, somewhere in the body of the HTML, the script starts by opening the PHP code with the symbol.

    在HTML文件中,位于HTML主体内的某个位置,该脚本首先打开带有符号PHP代码

  2. Next, the code uses the print( ) function to send the date it is about to generate to the browser.

    接下来,代码使用print()函数将要生成的日期发送到浏览器。

  3. The date function is then used to generate the current day's date.

    然后使用date函数生成当前日期。

  4. Finally, the PHP script is closed using the ?> symbols.

    最后,使用?>符号关闭PHP脚本。

  5. The code returns to the body of the HTML file.

    该代码返回到HTML文件的正文。

关于那个有趣的日期格式 ( About That Funny-Looking Date Format )

PHP uses formatting options to format date output. The lower case "L"—or l—represents the day of the week Sunday through Saturday. F calls for a textual representation of a month such as January. The day of the month is indicated by d, and Y is the representation for a year, such as 2017. Other formatting parameters can be seen at the PHP website.

PHP使用格式化选项来格式化日期输出。 小写字母“ L”(或l)代表星期日至星期六的星期几。 F要求以文本形式表示月份,例如January。 d表示月份中的日期,Y表示年份,例如2017。其他格式化参数可以在PHP网站上看到。

翻译自: https://www.thoughtco.com/todays-date-using-php-2693828

php 今天日期

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值