[pLog-svn] r1930 - plog/trunk/class/data
oscar at devel.plogworld.net
oscar at devel.plogworld.net
Mon May 2 22:20:36 GMT 2005
Author: oscar
Date: 2005-05-02 22:20:35 +0000 (Mon, 02 May 2005)
New Revision: 1930
Modified:
plog/trunk/class/data/timestamp.class.php
Log:
added Timestamp::parseDate() so that we can deal with additional date formats.
Modified: plog/trunk/class/data/timestamp.class.php
===================================================================
--- plog/trunk/class/data/timestamp.class.php 2005-05-02 21:50:26 UTC (rev 1929)
+++ plog/trunk/class/data/timestamp.class.php 2005-05-02 22:20:35 UTC (rev 1930)
@@ -32,7 +32,11 @@
* - DATE_FORMAT_TIMESTAMP (YYYYMMDDHHMMSS)
* - DATE_FORMAT_UNIXTIME (seconds since the unix epoch)
*
+ * Use the static method Timestamp::parseDate() in order to use other date formats which are not directly
+ * supported by this class.
+ *
* @see Date
+ * @see Timestamp::parseDate()
*/
class Timestamp extends Date
{
@@ -362,5 +366,26 @@
{
return( range( $minYear, $maxYear ));
}
+
+ /**
+ * Given a string with a date in whatever format, returns a valid Timestamp object
+ * The date will be parsed via PHP's strtotime()
+ * (http://fi2.php.net/manual/en/function.strtotime.php)
+ *
+ * @param dateString a string representing a date.
+ * @return a valid Timestamp object
+ * @static
+ */
+ function parseDate( $dateString )
+ {
+ // parse the date via strtotime
+ $timestamp = strtotime( $dateString );
+
+ // convert the unix timestamp to a Timestamp object
+ $date = new Timestamp( $timestamp );
+
+ // and return the whole thing
+ return( $date );
+ }
}
?>
\ No newline at end of file
More information about the pLog-svn
mailing list