biggles1212 Posted January 18, 2015 Posted January 18, 2015 Have a webpage where the date is required to be entered. The issue is it requires it in mm/dd order it seems. Any way to convert the dd/mm/yyyy while it sends to the database?
webko Posted January 19, 2015 Posted January 19, 2015 Under the hood, FileMaker always wants mm/dd/yyyy It may display it differently but... If the web form input is in dd/mm/yyyy (use a JavaScript date picker for this bit) then you can convert for input: $date_input = $_POST(date); $date_array = explode ("/"; $date_input); $date_toFM = $date_array[1]."/".$date_array[0]."/".$date_array[2]; And input the $date_toFM variable to the database I think that should work - been a while since I wrote code...
biggles1212 Posted January 19, 2015 Author Posted January 19, 2015 I hate to be a pain but where am I pasting that code? I assumed in the header of the search results page but I just get a blank white screen.
webko Posted January 19, 2015 Posted January 19, 2015 So I'll assume that you are doing a search on a date, from a search form... The above would need to be in the php section at the top, and before the actual search query, with the search query using the $date_toFM variable for the date part of it... If you paste your code for the search results page, I should be able to check it fairly quickly
webko Posted January 20, 2015 Posted January 20, 2015 Cool... try: <?php //Setup date to be in US format from AU format $date_input = $_REQUEST['Date_Start']; $date_array = explode ("/"; $date_input); $date_toFM = $date_array[1]."/".$date_array[0]."/".$date_array[2]; $search_bookings_results_find = $Marthakal->newFindCommand('Booking'); //Note Date_start is using the $date_toFM valye from above $search_bookings_results_findCriterions = array('Date_Start'=>$date_toFM,'Event_Resource'=>$_REQUEST['Event_Resource'],'triprecordnumber'=>$_REQUEST['triprecordnumber'],'payment_receipt no'=>$_REQUEST['payment_receipt_no'],'Status_Option'=>'=='.fmsEscape('Set As Paid'),'Pilot'=>$_REQUEST['Pilot'],); foreach($search_bookings_results_findCriterions as $key=>$value) { $search_bookings_results_find->AddFindCriterion($key,$value); } fmsSetPage($search_bookings_results_find,'search_bookings_results',50); $search_bookings_results_find->addSortRule('Date_Start',1,FILEMAKER_SORT_DESCEND); $search_bookings_results_result = $search_bookings_results_find->execute(); if(FileMaker::isError($search_bookings_results_result)) fmsTrapError($search_bookings_results_result,"searcherror.php"); fmsSetLastPage($search_bookings_results_result,'search_bookings_results',50); $search_bookings_results_row = current($search_bookings_results_result->getRecords()); $search_bookings_results__ClientBooking_portal = fmsRelatedRecord($search_bookings_results_row, 'Client_Booking'); $search_bookings_results__BookingClients_portal = fmsRelatedRecord($search_bookings_results_row, 'Booking_Clients'); $search_bookings_results__BookingManifest_portal = fmsRelatedRecord($search_bookings_results_row, 'Booking_Manifest'); // FMStudio Pro - do not remove comment, needed for DreamWeaver support ?>
webko Posted January 20, 2015 Posted January 20, 2015 Ah crud - spend too much time in straight FM scripting... Try: $date_array = explode ("/", $date_input); (comma in the middle, not semicolon)
biggles1212 Posted January 20, 2015 Author Posted January 20, 2015 Thank you so much. Worked perfectly. Definitely still learning how all this works :S
Recommended Posts
This topic is 3862 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now