Client LoginView your Shopping CartHelp & Frequently Asked QuestionsEmail Us
Home Services Portfolio Web Design Pricing Dreamweaver Templates Web Applications Free Tutorials About Contact Us
Services > CSS Web Design | Professional Logo Design | ASP.net, ASP & PHP Programming | Flash Animation & Programming | Reliable Web Hosting | Website Maintenance
Portfolio > Web Design Portfolio | Web Programming Portfolio | Logo Design Portfolio | Web Design Pricing > Custom Web Design | Logo Design | Business Card Design
Free Web Design Guide > Website Design w/ Dreamweaver & Fireworks | Adobe Fireworks CS4 review | Photo Effects | Text Effects | Graphic Design Ideas | Web Design Ideas
Website Navigation Ideas | CSS Styles Tutorial | Dreamweaver Template | Server Side Includes | Flash Tutorials > Flash Effects | Flash Sound Button | Sound On/Off Button
Flash Preloader | Import External Data | Promotion > SEO Tips | Google Tips & Page Rank | JavaScript > Date Validation | Email Validation | Phone Validation | Tip Boxes

Date Functions in PHP

In this tutorial you will learn about some Date functions in PHP.

  1. Getting the Current Date
  2. Getting Number of days in a month
  3. Check the date format

For Date Formats refer: PHP Date Function Tips

1. Getting the Current Date

The PHP function 'date' is used to display the current date in the specified format as indicated by its arguments as shown in the above example. For more details on date format arguments, click PHP Date Function Tips.

Syntax

date('format options');

Example:

1.date('y m d'); Output: 05 04 23

2. date('Y M D'); Output: 2005 Apr Sat

3.date('Y m d h: s: m'); Output: 2005 04 23 02: 18: 04 (Date and Time)

2. Number of days in a month

The function 'cal_days_in_month' is used to return the number of days in a month. This function takes three arguments one for calendar name, month value and year value respectively.

Syntax

cal_days_in_month( CAL_GREGORIAN, $intMonth, $intYear);

Example:

cal_days_in_month ( CAL_GREGORIAN, 1, 2005); Output: 31

3. Check the date format

The function 'checkdate' is used to check whether the date passed as an argument is a valid date or not. The function returns a boolean value of '1' if the date is a valid date and 'Null' if the date is invalid.

Syntax

checkdate ($intMonth,$date, $intYear);

Example:

1. checkdate (1, 30,2005); Output: (1 means true)

2. checkdate (2, 30,2005); Output: (null means false)

That's it you have learnt about some of the most commonly used date functions in PHP.

Absolutely FREE Web Templates
Check out these quality free web templates and download them without any registration or sign-up!

FREE Web Design Guide
From web design tips & ideas to HTML, CSS Styles, Fireworks & Dreamweaver you'll find all you need to know about effective web site design right here!

Quality Dreamweaver Templates
Professional quality dreamweaver templates in over 20 categories, starting at just $9.95! Instant download & easy customization

Beauty Templates | Business Templates | Christian Templates | CSS Templates | Education Templates | Family Templates | Flash Templates | Free Dreamweaver Templates
Food Templates | General Templates | Government Templates | Health/Medical Templates | Hi-Tech Templates | Kids/Childcare Templates | Low-cost Budget Templates
Personal Templates | Pets Templates | Photography Templates | Profession Templates | Real Estate Templates | Sports Templates | Telecom Templates | Travel Templates
Free Tutorials > Web Design Tutorials | CSS Web Design | Fireworks Tutorials | Dreamweaver Tutorials | Flash Tutorials | SEO Tutorials | Javascript Tutorials | PHP Tutorials