- 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
strtotime() function in PHP
The strtotime() function parses an English textual date or time into a Unix timestamp. It returns a timestamp on success, FALSE otherwise. Previous to PHP 5.1.0, this function would return -1 on failure.
Syntax
strtotime(time, now)
Parameters
time − Specifies the time string to parse.
now − The timestamp used to calculate the returned value.
Return
The strtotime() function returns a timestamp on success, FALSE otherwise. Previous to PHP 5.1.0, this function would return -1 on failure.
Example
The following is an example −
<?php $timestamp = strtotime( "June 20, 2018" ); print date( 'Y-m-d', $timestamp ); ?>
Output
2018-06-20
Example
Let us see another example −
<?php echo(strtotime("now") . "<br>"); echo(strtotime("10 March 2018") . "<br>"); echo(strtotime("+10 hours") . "<br>"); ?>
Output
1539235161 1520640000 1539271161
Advertisements
To Continue Learning Please Login
Login with Google