
1.新建一个php文件,命名为test.php,用于讲解php如何只获得当前时间的时分秒

2.在test.php文件中,使用header()方法将页面的编码格式设置为utf-8

3.在test.php文件中,使用time函数获得当时时间的时间戳.

4.在test.php文件中,通过date函数将当前的时间戳转换为时分秒格式.

5.在test.php文件中,使用echo输出时分秒

6.在浏览器打开test.php文件,查看结果

总结:
1、使用time函数获得当时时间的时间戳
2、通过date函数将当前的时间戳转换为时分秒格式
3、在使用echo输出时分秒
4、在浏览器打开test.php文件,查看结果