Unix Timestamps

In this tutorial I will show you how to use the time() funtion.

First of all, what it does:
The time() function simply returns the number of seconds since the Unix Epoch wich is: January 1 1970 00:00:00
You'll probably see this date again alot of times,
because if you for some reason mess up your code,
time() will just return this date.

time() returns a int like this:


Now, it's hard to tell what time and date it is just by looking at that number,
but we can use along with the date() function:

<?php echo date("F j Y H:i:s", 1123642727); ?>

This code outputs: August 10 2005 04:58:47
OH MY! I better be going to bed soon :P

-So, what can you use this code for?
Lets say you're making a news posting system.
And you just add the current date to the database or whatever like this: "August 10 2005".
What if you want to change that later? Like including the time it was posted and such?
It would be much easier if you just stored the timestamp in database,
then you can format it whenever you want to.

Want to get in touch? Got some feedback for me? or a couple of requests? Follow me at twitter:

Need a reliable webhost? Take my word for it and go with Hostgator Green Web Hosting by HostGator

Warning: fread(): Length parameter must be greater than 0 in /customers/f/2/7/n1studios.net/httpd.www/minicounter.php on line 17