« MBS Xojo / Real Studi… | Home | MBS Xojo Developer Co… »

Introducing FormatDateMBS function

Well, we have a problem. We need to format dates for our users. But not like date.shortDate where you get the date formatted in the settings of the current computer. We need to format the date in a web application with the date format of the user. And for this case, we added a FormatDateMBS function.

FormatDateMBS takes a format string, a date object and optional a locale identifier. If you don't pass an identifier, you typically get english, but if you pass an identifier, you can select which language and region is used for localization. Also with format text you can specify what to output. Just a part of date or time like the current year, the preferred date/time formats or one of the standard ones. Like you can specify "%x" for the preferred date presentation and "%X" for the preferred time presentation. Like this example:

dim d as new date
MsgBox FormatDateMBS("%x", d, "de_DE")
MsgBox FormatDateMBS("%x", d, "ja_JP")

The locale identifiers are platform dependent. On Mac, you use for German "de_DE". On Windows you use "ger" and on Linux you would use "de_DE.UTF8".

We hope this function (and also FormatMBS for numbers) help you making better web applications. Just check what locales you want to support and assign one to each user. Than use the user's setting for all format requests.
26 05 13 - 17:03
No comments

Remember personal info?

Emoticons / Textile

Hide email:

Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.