Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 5910 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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

Posted

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.

Posted (edited)

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
Posted (edited)

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...
Posted

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!

This topic is 5910 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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