iTech College - Internet Technology, Online Education, E-Learning, Technician Training, Tech Tutorials, Distance Education, Virtual Learning PHP Course: Date and Time - www.itechcollege.com PHP Course: Date and Time - www.itechcollege.com
Online Degrees Scholarships & Fellowships Internships Student Financial Aid Study Abroad Itech Bookstore
Free Courses
HTML
JavaScript
CSS
ASP
PHP
JSP
ASP.NET
SQL
AJAX
FTP
XML
Career Center
Job List
Web Jobs
Student Jobs
Computer Jobs
Engineer Jobs
Developer Jobs
Job Search
Resume Writing
Job Interview
Salary Info


itech > courses > PHP > Date and Time

Date and Time

To display current date/time, use:

echo date('F d, Y H:i:s');

The result will be something like:

August 08, 2008, 14:06:39

To display a certain date or time formatted in a certain way, use mktime() and date(). It takes two arguments: the format that describes how to print the date and the time stamp that represents the date you want to print.

<?php
$dataEntry = mktime(18,15,0,1,10,2001);
$x = date('F d, Y - g:i a',$dataEntry);

echo "$x"
?>

will produce:

January 10, 2001--6:15 p.m.

To deal with times in Greenwich Mean Time (GMT), you can use gmdate() and gmmktime(). For example, for a machine in eastern daylight time, which is four hours behind GMT:

<?php
$today = mktime(12,0,0,6,6,2001);
echo 'Here it is '.date('g:i:s a, F d, Y',$today);
echo '';
echo 'In GMT it is '.gmdate('g:i:s a, F d, Y',$today);
?>

will produce:

Here it is 12:00:00 pm, June 6, 2001
In GMT it is 4:00:00 pm, June 6, 2001

  Back to Index Page
Next Page >>   Basic Tags
Statements Comments and Characters
echo
Variables
Array
Loop
The If Statement
Function
Send and get Query String
Date and Time
Cookies
Environment Variables
Use Database
Create Graphics
 

PHP Books
PHP Jobs



Bookmark:  del.icio.us digg facebook Reddit Mixx BlinkList Fark Furl NewsVine Simpy Spurl Segnalo Technorati blogmarks Google YahooMyWeb Windows Live



PHP Course: Date and Time - www.itechcollege.com
Copyright ©2008, itechcollege.com. All rights reserved
iTechCollege | About iTech | Contact iTech