note 8620 added to Funciones de fecha y hora
| From: | ognio at peruserver dot com | Date: | Thu, 21 Sep 2000 09:56:08 +0000 |
| Subject: | note 8620 added to Funciones de fecha y hora | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-5271@lists.php.net to get a copy of this message | ||
Getting used to work with UNIX timestamps is not difficult.
A timestamp is just a computer-friendly form of representing a moment in time. It simply consists in
the number of seconds elapsed from the midnight of Jan-1-1970 which is called the "Epoch"
or Unix Epoch.
In PHP you'll get this number by calling
the time(); function. Now that you have this number you can use it for a variety of porpuses, mainly
querying for human-friendly information such as name of the day, name of month, hour, minutes,
seconds, year, etc. You get that info for your locale (e.g. your
local language if not english) using the
strfmktime() function.
The opposite (getting the timestamp from the "easy" parameters like hour, minute, second,
month, day, year, etc)
is done calling the mktime() function.
These 3 functions are the ones you'll be using the most of the time and there is lots of nice
things you will be able to do combining the three.
A fourth function you'll find very useful is checkdate(), so now you can
validate dates so you avoid 31th of April or February 30th.
If you're working with databases timestamps are very useful. They only
require standard integer numbers and allow you to very different later views
since you can query lots of information from this numbers.
In PostgreSQL I use int4 data types to save them.
So check'em out. Don't miss them :)
http://www.php.net/manual/es/ref.datetime.php