phpgroupware-developers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-developers] minor patch for mssql


From: Bradley Bell
Subject: [Phpgroupware-developers] minor patch for mssql
Date: Thu, 13 Dec 2001 18:54:05 -0800
User-agent: Mutt/1.2.5i

rather simplistic, but it works!

however, no matter how you implement these functions, it won't be perfect
because MSSQL doesn't return the number of seconds when I select a
datetime value!  Perhaps it's a freetds issue, I'm not sure.

e.g.:
$UnixTime = 1008295135; // 2001-12-13 17:58:55
$this->db->query("insert into foo (date) values 
('".$db->to_timestamp($UnixTime)."')");
$this->db->query("select date from foo");
while ($this->db->next_record()) {
    $date = $this->db->from_timestamp($this->db->f('date'));
    printf("Date: %s\n", $date);
}

will output:
Date: 1008295080

which is equal to: 2001-12-13 17:58:00

-brad

Index: phpgwapi/inc/class.db_mssql.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.db_mssql.inc.php,v
retrieving revision 1.19
diff -u -r1.19 class.db_mssql.inc.php
--- phpgwapi/inc/class.db_mssql.inc.php 2001/12/13 00:50:21     1.19
+++ phpgwapi/inc/class.db_mssql.inc.php 2001/12/14 02:15:27
@@ -99,15 +100,14 @@
                        return $this->Query_ID;
                }
 
-               // I don't have access to M$-SQL, can someone finish these 2 
functions ?  (jengo)
                function to_timestamp($epoch)
                {
-                       return False;
+                       return date('Y-m-d H:i:s',$epoch);
                }
 
                function from_timestamp($timestamp)
                {
-                       return False;
+                       return strtotime($timestamp);
                }
 
                // public: perform a query with limited result set

-- 
Bradley Bell
Computer Support Analyst
University of Washington
Classroom Support Services



reply via email to

[Prev in Thread] Current Thread [Next in Thread]