[geeklog-cvs] geeklog-1.3/public_html lib-common.php,1.406,1.407

blaine at iowaoutdoors.org blaine at iowaoutdoors.org
Wed Dec 22 11:10:32 EST 2004


Update of /var/cvs/geeklog-1.3/public_html
In directory www:/tmp/cvs-serv23745/public_html

Modified Files:
	lib-common.php 
Log Message:
Added new function COM_convertDate2Timestamp to convert a MySQL date-time string format YYYY-MM-DD HH:MM:SS to a UNIX Timestamp

Correction so that archive template is not used unless date is > archivedate timestamp.

Index: lib-common.php
===================================================================
RCS file: /var/cvs/geeklog-1.3/public_html/lib-common.php,v
retrieving revision 1.406
retrieving revision 1.407
diff -C2 -d -r1.406 -r1.407
*** lib-common.php	18 Dec 2004 14:15:36 -0000	1.406
--- lib-common.php	22 Dec 2004 16:10:28 -0000	1.407
***************
*** 6046,6049 ****
--- 6046,6074 ----
  }
  
+ /** Convert a text based date YYYY-MM-DD to a unix timestamp integer value 
+ *
+ * @param    string $date     Date in the format YYYY-MM-DD
+ * @param    string $time     Option time in the format HH:MM::SS
+ * @return   int          UNIX Timestamp
+ */
+ function COM_convertDate2Timestamp($date,$time='') {
+         // Breakup the string using either a space, fwd slash, bkwd slash or colon as a delimiter
+         $atok = strtok($date," /-\\:");
+         while ($atok !== FALSE) {
+             $atoks[] = $atok;
+             $atok = strtok(" /-\\:");  // get the next token
+         }
+         if ($time == '') {
+             $timestamp = mktime(0,0,0,$atoks[1],$atoks[2],$atoks[0]);
+         } else {
+             $btok = strtok($time," /-\\:");
+             while ($btok !== FALSE) {
+                 $btoks[] = $btok;
+                 $btok = strtok(" /-\\:");
+             }
+             $timestamp = mktime($btoks[0],$btoks[1],$btoks[2],$atoks[1],$atoks[2],$atoks[0]);
+         }
+         return $timestamp;
+ }
  // Now include all plugin functions
  foreach( $_PLUGINS as $pi_name )




More information about the geeklog-cvs mailing list