PHPBuilder - Date Manipulation in Php Page 2



RSS Twitter
Articles Php Functions

Date Manipulation in Php - Page 2

by: Allan Kent
|
July 30, 2000

Getting the current date and time

The way that Unix machines tell the time is by counting the number of seconds that have elapsed since Midnight 1 January 1970. They call this the Unix Epoch.
So if we had a piece of PHP that looked something like this:

<?php

echo time();

?>
it would return to me a result of
958905820
This just happens to be about 12h43 on Sunday 21 May 2000.
This is all well and good you may say, but how does that help me ? Well quite a bit actually. A lot of the functions that do date manipulation in PHP require the timestamp that is returned by the time() function as one of the inputs. Also, since PHP uses the timestamp in the same way under both Unix and Windows, it allows you to use code on either operating system without any problems. A further bonus is that since the time() function is returning an integer, you can store it as such in a database or text file - no more need for fancy date/time database fields.
OK, so now that you have the how and why about Unix timestamps, let's get on to the really important bits and start using it for something useful.


« Previous Page
1
|
2
|
3
|
4
|
5
|
6
|
7
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Allan Kent

Comment:



Comment:

(Maximum characters: 1200). You have characters left.