Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function split() is deprecated in /home3/vvaswani/public_html/community/columns/trog/article.php on line 101

Deprecated: Function eregi_replace() is deprecated in /home3/vvaswani/sql.php on line 301

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home3/vvaswani/public_html/community/columns/trog/article.php on line 107

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home3/vvaswani/public_html/community/columns/trog/article.php on line 109

Deprecated: Function ereg_replace() is deprecated in /home3/vvaswani/public_html/community/columns/trog/article.php on line 124

Deprecated: Function ereg_replace() is deprecated in /home3/vvaswani/public_html/community/columns/trog/article.php on line 125

Deprecated: Function split() is deprecated in /home3/vvaswani/public_html/community/columns/trog/article.php on line 127

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174

Deprecated: Function ereg() is deprecated in /home3/vvaswani/db-mysql.php on line 174
The Melonfire Community - Trog
Logo         Community
  Trog
Services
The Company
Community
Columns
Your Account
Contact Us
 
 
Date/Time Processing With PHP
Simplify date and time processing in your PHP scripts

| Checking Up |

Options to getdate() include the localtime() and gettimeofday() functions, both of which return arrays containing time information. Take a look:


<?
// get current time as array
$current = gettimeofday();

// print it
print_r($current);
?>


This would generate the following output:


Array
(
    [sec] => 1014189678
    [usec] => 900172
    [minuteswest] => -19800
    [dsttime] => 0
)


Alternatively, you can use the localtime() function, which calls the system's localtime() function and returns the output as an array containing information similar to that returned by getdate(). Take a look:


<?
// get current time as array
// the second parameter tells PHP to create an associative array
// omit it to create a regular integer-indexed array
$current = localtime(mktime(), TRUE);

// print it
print_r($current);
?>


Here's the output:


Array
(
    [tm_sec] => 51
    [tm_min] => 54
    [tm_hour] => 12
    [tm_mday] => 20
    [tm_mon] => 1
    [tm_year] => 102
    [tm_wday] => 3
    [tm_yday] => 50
    [tm_isdst] => 0
)


It's unlikely that you'll ever use these, since most of what they provide is already available via the functions discussed previously. However, they're included here in case you ever have a need for this specialized information.

Finally, the checkdate() function tells you whether a given date is valid or not. Consider the following examples:


<?
// 31-Feb-2002 - false
echo checkdate(02, 31, 2002);

// 25-Dec-1956 - true
echo checkdate(12, 25, 1956);

// 31-Jun-2002 - false
echo checkdate(06, 31, 2002);
?>


This function comes in particularly handy if you need to validate date information entered into an online form - simply run the datestamp via checkdate() to see whether or not it's valid.


How to do Everything with PHP & MySQL
How to do Everything with PHP & MySQL, the best-selling book by Melonfire, explains how to take full advantage of PHP's built-in support for MySQL and link the results of database queries to Web pages. You'll get full details on PHP programming and MySQL database development, and then you'll learn to use these two cutting-edge technologies together. Easy-to-follow sample applications include a PHP online shopping cart, a MySQL order tracking system, and a PHP/MySQL news publishing system.

Read more, or grab your copy now!


previous page more like this  print this article  next page
 
Search...
 
In trog...
Logging With PHP
Building A Quick-And-Dirty PHP/MySQL Publishing System
Output Buffering With PHP
Creating Web Calendars With The PEAR Calendar Class
Caching Web Sites With PEAR Cache
more...
 
In the hitg report...
Crime Scenes
Animal Attraction
Lord Of The Strings
more...
 
In boombox...
Patience - George Michael
Think Tank - Blur
My Private Nation - Train
more...
 
In colophon...
Hostage - Robert Crais
The Dead Heart - Douglas Kennedy
Right As Rain - George Pelecanos
more...
 
In cut!...
American Chai
The Core
Possession
more...
 
Find out how you can use this article on your own Web site!


Copyright © 1998-
Strict Standards: mktime(): You should be using the time() function instead in /home3/vvaswani/public_html/community/columns/trog/article.php on line 731
2018 Melonfire. All rights reserved
Terms and Conditions | Feedback