简体   繁体   English

PHP中的时间函数

[英]time function in php

Somehow I managed to make the date work, 我设法使日期生效了,

<td width="67"><font size="3"><b>*Date</b></td>
<td width="3">:</td>
<td width="168"><input name="adate" type="text" id="adate" maxlength="20" value="<?php  echo date("Y/m/d") . "<br />"; ?>">

how do I echo the time in this form: 我如何以这种形式呼应时间:

  <td width="67"><font size="3"><b>*Time</b></td>
    <td width="3">:</td>
    <td width="168"><input name="adtime" type="text" id="adtime" maxlength="15">

    </td>

simply use the date function but with hour/min/seconds output.. 只需使用日期功能,但输出时/分/秒。

echo date('H:i:s');

Date Function 日期功能

My advice if your programming in PHP go with a framework like CodeIgniter, CakePHP or Zend. 我的建议是,如果您使用PHP 进行编程, 请使用 CodeIgniter,CakePHP或Zend之类的框架 Just dont code from scratch out of thin air unless you actually need to. 除非确实需要,否则请不要从头开始进行编码。

Depends on what format you want for the time. 取决于您想要的时间格式。

the php date() function has a number of different ways of representing time. php date()函数具有多种表示时间的方式。 If you just want HH:MM:SS you could do this: 如果只需要HH:MM:SS,则可以执行以下操作:

<td width="168"><input name="adtime" type="text" id="adtime" maxlength="15" value="<?php  echo date("H:i:s") ?>">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM