Take the 2-minute tour ×

I'm using PHP + SQLSRV extension along with a MSSQL database (2008). When querying I was getting date objects for the date fields, by using "ReturnDatesAsStrings" parameter for sqlsrv_connect function I was able to get a string date instead of objects. I was wondering if there's a similar way for setting up date formats (pass a format when establishing a connection) so I don't need format it from app's end.

share|improve this question

1 Answer 1

I ran into the same problem, by any chance where you using Codeigniter's activerecord?

this is how I solved it with activerecord,:

// returns true on successful update
public function last_touched($user_id)
    // the format used in ISO 8601
    $time = date("Y-m-d"); // = "2013-06-10"

    $sql_query  = "UPDATE Users ";
    $sql_query .= "SET Modified= '{$time}' ";
    $sql_query .= "WHERE ID= '{$user_id}'";
    return $this->db->query($sql_query);
share|improve this answer

Your Answer


