PHP - Function strtotime()


Advertisements


Syntax

int strtotime ( string $time [, int $now] );

Definition and Usage

The function expects to be given a string containing a US English date format and will try to parse that format into a Unix timestamp elative to the timestamp given in now, or the current time if none is supplied.

Parameters

Sr.No Parameter & Description
1

time(Required)

It specifies the time string to parse

2

now(Optional)

The timestamp used to calculate the returned value.

Return Value

It returns a timestamp on success, FALSE otherwise. Previous to PHP 5.1.0, this function would return -1 on failure.

Example

Following is the usage of this function −

Live Demo
<?php
   $timestamp = strtotime( "February 15, 2015" );
   
   print date( 'Y-m-d', $timestamp );
?>

This will the produce following result −

2015-02-15

php_function_reference.htm

Advertisements