Amazon.com: PC Books || Educational Software || Magazines
Amazon: Books-CA || Software-CA || Books-UK || Software-UK

HTML | Javascript | ASP | PHP | VBScript | SQL | Hardware | PC FAQ| WinXP|

Learn to Build, Upgrade, or Repair your Computer Ebook + PC Safety 101 kwwebservice.com Reasonably priced web development & hosting
PHP Basics
Introduction
Variables & Arrays
Sub & Functions
If Statements
Case Statements
Loop Statements
Date Objects
Form Processing
Text File Objects
Database Access
Adding Record
Updating Record
Deleting Record
Virtual Includes
Cookies
Session
Server Variables
Creating Login Page
E-mail
PHP Books @
CA Amazon
UK Amazon
US Amazon

  :: Home
PC Topics
  :: Build A PC
  :: Windows XP
  :: PC Help
Tutorials
  :: HTML
  :: JavaScript
  :: ASP
  :: PHP
  :: VBScript
  :: SQL
Miscellaneous
  :: Code/Scripts
  :: Forum
  :: Links
  :: Contact us
  :: Tell A Friend
  :: In Somali
  ::
Web Articles
  Top Web Hosting
Reviews
  Processing
Online Card Payment Guide
  Domain name
registration & buying guide
  Getting
a website online guide
  Search Engine
submission & optimization tips
Netfirms Web Hosting
Free trial
Quality business correspondence.
Yahoo! Search Marketing

Displaying Date & Time with PHP

You use date() with string argument to get the current date or time. You might also use the function now() to get the current date & time.
For example, these examples will Illustrate use of date and time functions.
ExampleFunction Result
<?php echo date("F j, Y"); ?> Month name, day & full year May 9, 2008
<?php echo date("m/d/y"); ?> Mont/day/short year 05/09/08
<?php echo date("Ymd"); ?> Full year, month and day 20080509
<?php echo date("d"); ?> Digit day 09
<?php echo date("j"); ?> Digit day-no leading 0 9
<?php echo date("D"); ?> Day name Fri
<?php echo date("m"); ?> Digit month 05
<?php echo date("n"); ?> Digit month-no leading 0 5
<?php echo date("M"); ?> Short month name May
<?php echo date("F"); ?> Full month name May
<?php echo date("t"); ?> # of days in current month 31
<?php echo date("y"); ?> Short Year 08
<?php echo date("Y"); ?> Full year 2008
<?php echo date("w"); ?> Day of week 0-Sun 6-Sat 5
<?php echo date("z"); ?> Day of year 0-to-365 129
<?php echo date("W"); ?> Current week of the year (53w) 19
<?php echo date("W"); ?> Currently week of the year (53w) 19
<?php echo date("a"); ?> am or pm pm
<?php echo date("A"); ?> AM or PM PM
<?php echo date("g"); ?> 12h format 7
<?php echo date("G"); ?> 24h format 19
<?php echo date("h"); ?> 12h format with leading 0 07
<?php echo date("H"); ?> 24h with leading 0 19
<?php echo date("i"); ?> Minutes 46
<?php echo date("s"); ?> Seconds 14
<?php echo date("T"); ?> Timezon MDT
Following example utilizes Date() function to illustrate more.
<?php
  print "Today's date is: ";
  print date("F j, Y");
  print " and there is ";
  print 365-date("z");
  print " days left of the year ";
  print date("Y");
?>

Execution Result: Today's date is: May 9, 2008 and there is 236 days left of the year 2008
Loops Database Access
Bluehost.com Web Hosting $6.95
PC System Tools
SpyCleaner
Registry Mechanic
4Diskclean Pro
Health PC Club
TweakNow
Registry Washer
SpyAnyWhere
System Lifeguard
...More/Details

PC Articles
  Computer Safety
prevent viruses & Spyware