- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
time() function in PHP
The time() function in PHP returns the current time as a Unix timestamp. It returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).
Syntax
time()
Parameters
NA
Return
The time() function returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).
Example
The following is an example −
<?php $nextWeek = time() + (7 * 24 * 60 * 60); echo 'Now: '. date('Y-m-d') ."
"; echo 'Next Week: '. date('Y-m-d', $nextWeek) ."
"; ?>
Output
The following is the output −
Now: 2018-10-11 Next Week: 2018-10-18
Example
Let us see another example −
<?php $res = time(); echo($res . "<br>"); echo(date("Y-m-d",$res)); ?>
Output
The following is the output −
1539245504 2018-10-11
Advertisements