PHP

 Home  Computers & Internet  Web Programming PHP
What is PHP?
Echo
Comments
Variables
Constants
Data Types
number_format()
Character Strings
Mathematical Operators
Comparison Operators
Logical Operators
Joining Strings
explode()
implode()
strtolower()
strtoupper()
strlen()
ucfirst()
ucwords()
strrev()
str_replace()
str_repeat()
trim()
strip_tags()
addslashes()
stripslashes()
strpos()
strrpos()
nl2br()
isset()
unset()
empty()
POST
GET
If Statements
If Else Statements
Elseif Statements
Switch Statements
For Loops
While Loops
Do While Loops
Foreach Loops
File Create
File Open
File Read
File Write
File Delete
fgets()
file_get_contents()
Date & Time
$_SERVER
Sessions
Cookies
Arrays

WHAT THE time() FUNCTION DOES IN PHP AND HOW TO USE IT

The time() function returns the current Unix Timestamp in seconds since 00:00:00 GMT on 1 January 1970.

The general format of the date function is as follows:

time();

If you echo this you will get:

1328569896

Whilst this might not make sense on it's own, you could probably use this function for something like this.

$inTwoDays = time() + (2 * 24 * 60 * 60);// converting 2 days all to seconds
echo date("d-m-Y",$inTwoDays);

This will output:

08-02-2012

You use the time() function to form dates in future, present and past on the Unix timestamp seconds level and then format them to readable format as you require it.

See also:

date()
mktime()
gmdate()
strtotime()
microtime()




Home | Privacy Policy | Terms Of Use | Contact Us | Work At Home | Online Jobs | Smart Info | Online Jobs | Data Entry Jobs | Paid Surveys | Info | Info | Typing Jobs | Article Archive | Forum Posting Jobs