PHP Date

PHP Date


Posted in : PHP Posted on : January 21, 2011 at 4:01 PM Comments : [ 0 ]

This section contains the examples on date in PHP.

PHP Date

This section contains the detail about Date in PHP. The Date in PHP have various methods which allows you to pull out and format the Date and Time on server.

The php.ini file have the settings for date and time which is used by the date functions. You can change these setting according to you. Given below the settings(in php.ini) and its description :

Name Default Description
date.default_latitude  "31.7667" This option is available since PHP 5. Specifies the default latitude (). This option is used by date_sunrise() and date_sunset()
date.default_longitude "35.2333" This option is available since PHP 5.Specifies the default longitude (). This option is used by date_sunrise() and date_sunset()
date.sunrise_zenith "90.83" This option is available Specifies the default sunrise zenith (available since PHP 5). This option is used by date_sunrise() and date_sunset()
date.sunset_zenith "90.83" This option is available Specifies the default sunset zenith (available since PHP 5). This option is used by date_sunrise() and date_sunset()
date.timezone "" This option is available Specifies the default timezone (available since PHP 5.1)

Date( ) function

The Date() function in PHP is used to format date  and time. The syntax of the date function is given below :

date(format, timestamp)

The format in above syntax is necessary field and specifies the format of the timestamp.

The timestamp is optional and it specifies a timestamp. Default is the current date and time.

The given below is the example code to use a date function :

<?php
echo date("Y/m/d") . "<br />";
echo date("Y.m.d") . "<br />";
echo date("Y-m-d")
?> 

Output :

2009/05/11
2009.05.11
2009-05-11

Given below the complete list of examples on date in PHP :

 

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics