Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

Advanced Search Dates, Formats and Closed Date Search

Ive found a bug in my helpdesk which i need help with.

I changed the system date format to UK DD/MM/YY and also on the calander.js ive got it on the ADVANCED TICKET SEARCH to input into the Startdate and EndDate in this UK format, but the search is still relying on the US Style MM/DD/YY so the search is not working, this PHO code below looks to be the part where this is done, but need to add D-M-Y so the search understands that the inputting Start and End dates are UK format and not US.

Can anyone help fixing the date formatting of the search to understand that what is entered is DD/MM/YY and not MM//DD/YY

What i ultimately want to do once this is working, is have a tick box next to the search dates which says the Start Date and End Date search entries are the CLOSED date instead instead of the OPEN date range. So if box is checked the range entered is searching for closed date of the tickets and not the default of OPEN.

Can anyone help with that also ?

Cheers

 //dates
$startTime =($_REQUEST['startDate'] && (strlen($_REQUEST['startDate'])>=8))?strtotime($_REQUEST['startDate']):0;
$endTime =($_REQUEST['endDate'] && (strlen($_REQUEST['endDate'])>=8))?strtotime($_REQUEST['endDate']):0;
if( ($startTime && $startTime>time()) or ($startTime>$endTime && $endTime>0)){
$errors['err']='Entered date span is invalid. Selection ignored.';
$startTime=$endTime=0;
}else{
//Have fun with dates.
if($startTime){
$qwhere.=' AND ticket.created>=FROM_UNIXTIME('.$startTime.')';
$qstr.='&startDate='.urlencode($_REQUEST['startDate']);

}
if($endTime){
$qwhere.=' AND ticket.created<=FROM_UNIXTIME('.$endTime.')';
$qstr.='&endDate='.urlencode($_REQUEST['endDate']);
}

Comments

  • I assume this is down to "strtotime" function only liking MM/DD/YYYY, how do i apply DD/MM/YYYY to this function to the code below?

    date("d-m-y", is something i keep seeing but cannot figure out how to add it to the code as im not that good with PHP and just cutting and pasting, please who can help?

    Thanks
  • Ive read this may work..... how do i implement this?

    list($d, $m, $y) = preg_split('/\//', $date);
    $date = $m.'/'.$d.'/'.$y;
  • Hi i managed to resolve it.

    Changed the calender.js to use - instead of / and therefore it knows it EU instead of US time.

    No i need to work out how to search CLOSED time of Tickets, im going to open a new thread.
Sign In or Register to comment.