timestamp

Phing Logo

Getting Time And Date Values In Phing

10th June 2011 - 5 minutes read time

The tstamp task in Phing can be used to generate a timestamp that can be used anywhere within the current project. The default behaviour of tstamp is to create the properties DSTAMP, TSTAMP and TODAY, which contain time and date values. All you need to do is include the tstamp XML tag in your project somewhere.

<tstamp>
</tstamp>

The properties DSTAMP, TSTAMP and TODAY use the PHP strftime() function as a basis for formatting the time. The following table shows the value of each property.

PHP Logo

Convert Time Into Timestamp Or Timestamp Into Time In PHP

10th May 2008 - 2 minutes read time

The easiest (and most reliable) way to store the time in a database table is with a timestamp. It is also the most convenient way of working out time scales as you don't have to do calculations in base 60. In MySQL this is accomplished by the UNIXTIME() function, which can be reversed by using another MySQL function called FROM_UNIXTIME().

However, you can sometimes be left with timestamps in your code and the task of trying to figure out what to do with them.

The first problem is trying to convert a timestamp into a date. So here is a PHP function that does this.