Tags
Asked 3 years ago
13 Jul 2021
Views 231
Amina

Amina posted

What is PHP time function ?

What is PHP time function ? How PHP time function works ? is time() give you current time in PHP ?
Mitul Dabhi

Mitul Dabhi
answered Jul 17 '21 00:00

is time() give you current time in PHP ?
Answer is yes time() function give you current time but in format of timestamp in PHP ?
as per php.net


time(): int



Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).



but the question is how to use a timestamp in php because we do need date and time mostly so question is
how to use time() function ?
Answer ::
you can use time function return in the date function as argument which give you as per need formatted date and time .

date('Y-m-d',time())

but you can use date() function without argument of the time() function return will give you same output
you can play with time by adding time and reducing time and get date and time with date() function in PHP
Post Answer