24 December 2008

Date() Functions

Php date function returns a formatted date string. Every call to a date/time function will generate a E_NOTICE, E_STRICT or E_WARNING if the time zone is not valid.

d - The day of the month (01 to 31)
m -Month (01 to 12)
Y - Year (in four digits)


Syntax :
date(format,timestamp)

Example :
echo date("Y M d", time());
echo date("Y-M-d", time());
echo date("Y / M / d", time());

Output today formated date : 2007 Dec 24, 2007-Dec-24 and 2007 / Dec /24


To get the future date, i.e tommrow :
$tomorrow = mktime(0,0,0,date("m"),date("d")+1,date("Y"));
echo "Tomorrow is ".date("Y/m/d", $tomorrow);
Output : Tomorrow is 2007/12/25

To get a date in the past or future dynamically is like this:

//get timestamp for past/future date I want
$pf_time = strtotime("-3 days");
//format the date using the timestamp generated
$pf_date = date("Y-m-d", $pf_time);

gmdate() - Format a GMT/UTC date/time
idate() - Format a local time/date as integer
getdate() - Get date/time information
getlastmod() - Gets time of last page modification
mktime() - Get Unix timestamp for a date
strftime() - Format a local time/date according to locale settings
time() - Return current Unix timestamp

30 April 2006

PHP Variables

Using Php Variables
Php Variables are are used for storing values, such as strings, numbers। Once stored they can be called from anywhere within the script।

Note :Variables can not have spaces and only contain alpha-numeric characters and underscores.
$myVar or $my_Var both is correct.



Output of this script is :
Hi Friend

Below is another example :


Output of is :
2 + 2 is 4