Results 1 to 2 of 2

Thread: Datetime discrepancy

  1. #1
    hadoob024's Avatar
    hadoob024 is offline Sugar Community Member
    Join Date
    Mar 2010
    Posts
    137

    Default Datetime discrepancy

    Here's the situation. I update some datetime fields in a "before save" hook like so:

    PHP Code:
    $userDate = new TimeDate();
    $date_format $userDate->get_date_time_format();
    $bean->decision_sent_date date($date_format); 
    This is fine. It stores the time in GMT in the db which displays fine in Sugar based on my timezone setting.


    In an "after save" hook, I try to update another field by the following:

    PHP Code:
    $db = & DBManagerFactory::getInstance();
    $updateLogisticsInDate "update tmpprocedure set logistics_in = GETDATE() where id = '".$bean->id."'";
    $db->query($updateLogisticsInDate); 

    This however saves a datetime value that is my local current time (EST). So, I just ran my script now, and "2010-12-22 00:17:00.000" gets stored for "decision_sent_date" (which is GMT), but "2010-12-21 19:17:44.067" gets stored for "logistics_in" (which is EST). How do I fix this so that I have consistent datetime values that get stored in the db?

    Thanks!
    Last edited by hadoob024; 2010-12-21 at 11:19 PM.
    -hadoob024-


    Windows 7 SP1
    PHP 5.2.17
    SQL Server 2008 R2
    IIS 7.5
    Sugar Professional Version 5.5.1

  2. #2
    hadoob024's Avatar
    hadoob024 is offline Sugar Community Member
    Join Date
    Mar 2010
    Posts
    137

    Default Re: Datetime discrepancy

    Just figured it out. Instead of using GETDATE(). I do the following:

    PHP Code:
    $userDates = new TimeDate();
    $tmp $userDates->get_gmt_db_datetime();
    $updateLogisticsInDate "update tmpprocedure set logistics_in = '$tmp' where id = '".$bean->id."'"

    Now everything looks good!
    -hadoob024-


    Windows 7 SP1
    PHP 5.2.17
    SQL Server 2008 R2
    IIS 7.5
    Sugar Professional Version 5.5.1

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Reports PDF discrepancy
    By ITTCorp in forum Help
    Replies: 0
    Last Post: 2008-07-16, 06:33 PM
  2. Cant use DateTime Combo
    By ztolley in forum Developer Help
    Replies: 0
    Last Post: 2008-04-14, 01:17 PM
  3. datetime format
    By bogo123 in forum Help
    Replies: 0
    Last Post: 2008-02-13, 10:05 AM
  4. DateTime class
    By denis.witt in forum Installation and Upgrade Help
    Replies: 2
    Last Post: 2006-12-06, 08:46 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •