search
HomeBackend DevelopmentPHP ProblemHow to get the current time in php

In PHP, the time() function can be used with the date() function to get what time it is currently. When the parameters of the date() function are set to "'h:i:s'", you can Get the current time, the syntax is "date('h:i:s', time());".

How to get the current time in php

The operating environment of this article: Windows 10 system, PHP version 7.1, Dell G3 computer.

How to get the current time in php

The time() function returns the number of seconds of the current time since the Unix epoch (January 1 1970 00:00:00 GMT).

The syntax is:

time();

Return value:

Returns an integer containing the Unix timestamp of the current time.​

date() function is used to format time/date.

The date() function formats the timestamp into a more readable date and time.

Syntax

string date ( string $format [, int $timestamp ] )

Parameter Description

format Required. Specifies the format of the timestamp.

timestamp Optional. Specify timestamp. The default is the current date and time.

The example is as follows:

<?php
echo date(&#39;h:i:s&#39;, time()); 
?>

The output result is the current time

How to get the current time in php

Recommended study:《 PHP video tutorial

The above is the detailed content of How to get the current time in php. For more information, please follow other related articles on the PHP Chinese website!

Statement
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 AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools