PHP: DATETIME help -
i know there's ample information datetimes on internet i'm having trouble using i've been seeing.
i have calander control hooked text box. takes in form 15/11/2010 (british). use query datetime fields in sql server db in format 15/11/2010 00:00:00.
after capture dates on postback pass values onto method attempts convert text time format. when query between 01/01/2010 , 01/07/2010 number of results. when change between 01/01/2010 , 30/10/2010 error. error invalid foreach (haven't caught error yet). i'm guessing formats?
function getsupportticketsbysubissueanddate($subissueid, $from, $to){ $subissueid = $this->ms_escape_string($subissueid); $from = date("dd/mm/yy", strtotime($from)); $to = date("dd/mm/yy", strtotime($to)); $connection = new connections(); $conn = $connection->connecttowarehouse(); $atid = $_session['saveddata']['autotaskid']; $tsql = "select wh_task.task_id, wh_task.task_name, wh_task.task_description, wh_task.task_number, wh_task.reported_by_name, wh_task.create_time, wh_resource.first_name, wh_resource.last_name, wh_task_status.task_status_name ". "from wh_task_status inner join (wh_task inner join wh_resource on wh_task.assigned_resource_id = wh_resource.resource_id) on wh_task_status.task_status_id = wh_task.task_status_id ". "where (account_id = $atid) , (subissue_type_id = $subissueid) , (((wh_task.create_time) between '$from' , '$to'))". "order create_time desc"; // set array hold each of issue types , number of tickets in each $ticket; $stmt = sqlsrv_query( $conn, $tsql); if( $stmt === false) { echo "error in query preparation/execution.\n"; die( print_r( sqlsrv_errors(), true)); } $x = 0; /* retrieve each row associative array , display results.*/ while( $row = sqlsrv_fetch_array( $stmt, sqlsrv_fetch_assoc)) { $ticket[$x][0] = $row['task_name']; $ticket[$x][1] = $row['task_description']; $ticket[$x][2] = $row['task_number']; $ticket[$x][3] = $row['reported_by_name']; $ticket[$x][4] = $row['first_name']; $ticket[$x][5] = $row['last_name']; $ticket[$x][6] = $row['task_status_name']; $ticket[$x][7] = $row['create_time']; $ticket[$x][8] = $row['task_id']; $x++; } return $ticket; }
any appreciated!
jonesy
i'm unsure if you're formatting dates correctly. can find formatting rules @ bottom through url posted
date("dd/mm/yy ...
that's not gonna work cause that's not how they're formatted in php. this:
date("d/m/y ...
will change format dd/mm/yy. :)
Comments
Post a Comment