Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Searching Date Fields - Format as DD/MM/YYYY

Featured Replies

I have a date field on a search page that was created with the PHP Site Assistant. I want it to use the DD/MM/YYYY format as that

is how the database is setup and all our computers use that date format. I've just discovered by comparing a search via the web

browser and a search in the FileMaker database that web searches on the date field are using the MM/DD/YYYY format instead of the

DD/MM/YYYY format. On the findrecords.php search page there is this PHP code which I presume is relevant:

// formats for dates and times

    $displayDateFormat = '%d/%m/%Y';

    $displayTimeFormat = '%H:%M';

    $displayDateTimeFormat = '%d/%m/%Y %H:%M';

    $submitDateOrder = 'dmy';




and on the recordlist.php page there is this code which I presume is relevant:




// formats for dates and times

    $displayDateFormat = '%d/%m/%Y';

    $displayTimeFormat = '%H:%M';

    $displayDateTimeFormat = '%d/%m/%Y %H:%M';

    $submitDateOrder = 'dmy';

    $record = NULL;

    $findCom = NULL;

This is my first PHP site so I'm learning as I go but would appreciate it if anyone can tell me what changes I need to make to get

the search to work in the DD/MM/YYYY format?

Many thanks,

Steve

by:

the search to work in the DD/MM/YYYY format?

Do you want to change the format that displays on your web page or the format that gets sent to the Command Find? I've never used the site assistant so I don't know what code it spits out. Those strings look like a cross between the formatting options for date() and printf() without knowing what functions it's using to format I can't help you much.

If you want change the format of the displayed data I'll need to see the code that prints it to the screen along with the code that sets any variables that get used.

If you want to change the data that gets submitted to the command find I'll need to see the addFindCriterion() code for a date along with the code that sets any variables that get used.

  • Author

Thanks for the reply. I'm only interested in the submission of dates that the user has entered into a field on the search form. We only allow the user to search on a date field and do not display them on any of the results pages.

I've attached the fmview.php (renamed to fmview.txt so I could upload it). It's much more complex that I can deal with at the moment as I'm new to PHP and learning as I go and there's multiple date references in there. If you can see where to make the change I would be very appreciative.

Thanks,

Steve

fmview.txt

Edited by Guest

This is just a guess. I'm assuming Date.php contains PEAR's Date class and would need to see whatever code calls the submitDate() function to be sure, but try changing Line 346 (should be in the SubmitDate() function).

From: return $d->format("%m/%d/%Y");

To: return $d->format("%d/%m/%Y");

my Copy of PEAR::Date (1.4.6) has a reasonable description of the formatting options in a comment from line 284 - 326 just above the format function.

Edited by Guest
preposition trouble

  • 1 month later...

Hi fmwebby,....

It seems internally the Filemaker php API works with american date formats. This means that dates have to be converted when output or input.

Use the method displayDate( $theDateFromFileMaker, $displayDateFormat ) to convert from US to your preferred date format.

Use the method submitdate( $theDateFromTheUser, submitDateOrder ) to reconvert the input date into US-format.

The php Site-Assistant has a hack whereby they just 'submit' the american date format to the user, because they haven't programmed the conversion of the date at submit-time!

This means that - until further notice or at least further programming - all dates hve to be entered good ol' US-style!

that should of course read

submitDate( $theDateFromTheUser, $submitDateOrder )

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.