Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online

strtotime function syntax tag tutorial 2013





Alert! Connect with 10,000 Chating Online. Join Now

Php strtotime () function

Write your php code

 
<?php ?>

Php Result


Your code below



(PHP 3>= 3.0.12, PHP 4 , PHP 5)

strtotime --  Parse about any English textual datetime description into a Unix timestamp

Syntax

int strtotime ( string time [, int now] )

The function expects to be given a string containing an English date format and will try to parse that format into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 GMT), relative to the timestamp given in now, or the current time if none is supplied. Upon failure, -1 is returned.

Because strtotime() behaves according to GNU date syntax, have a look at the GNU manual page titled Date Input Formats. Described there is valid syntax for the time parameter.

Warning

In PHP 5 up to 5.0.2, "now" and other relative times are wrongly computed from today's midnight. It differs from other versions where it is correctly computed from current time.

Example 1. strtotime() examples

<?php
echo strtotime("now"), "\n";
echo
strtotime("10 September 2000"), "\n";
echo
strtotime("+1 day"), "\n";
echo
strtotime("+1 week"), "\n";
echo
strtotime("+1 week 2 days 4 hours 2 seconds"), "\n";
echo
strtotime("next Thursday"), "\n";
echo
strtotime("last Monday"), "\n";
?>

Example 2. Checking for failure

<?php
$str
= 'Not Good';
if ((
$timestamp = strtotime($str)) === -1) {
    echo
"The string ($str) is bogus";
} else {
    echo
"$str == " . date('l dS of F Y h:i:s A', $timestamp);
}
?>

Note: The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer.) Additionally, not all platforms support negative timestamps, therefore your date range may be limited to no earlier than the Unix epoch. This means that e.g. dates prior to Jan 1, 1970 will not work on Windows, some Linux distributions, and a few other operating systems.

Php strtotime Function syntax tag

strtotime php code on this is provided for your study purpose, it will guide you to know how create and design a website using php. use it to practice and train your self online



Php strtotime syntax tutorial

php tutorial guide and code design are for easy learning and programming. The code practice section provided at the top is for practising of this syntax. Use the code section up to practice your php programming online. Learning php is very easy, all you need is to use the examples on this site and practice them to perfect your skills.


Function index

Variables

Expressions

Operators

Control-Structures

Cookies

Array

Date & Time

Directory function

File

Image

Operators

Form data handling

Mathematics operators

Mail

Php Mysql

Network Functions

Strings

php tutorial guides,functions, classes, code examples and tags for creating simple dynamic site to mysql database driven sites
 
 
Htaccess    html   Php    javascript   Asp   css    maths  Past Questions  Practice Tests Online