iOS Question DateTime and locale

Discussion in 'iOS Questions' started by Semen Matusovskiy, May 10, 2019.

  1. Semen Matusovskiy

    Semen Matusovskiy Well-Known Member Licensed User

    Hi, guys --

    Is it possible to set locale on fly for DateTime functions ?
    My app already has #PlistExtra: <key>CFBundleLocalizations</key> and this works fine, for example in textfield context menu. But there is no effect for DateTime.DateParse, DateTime.Date etc. Any ideas ?
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. Semen Matusovskiy

    Semen Matusovskiy Well-Known Member Licensed User

    Thanx for reply. I added a subroutine from your link

    Sub SetDateTimeLocale (locale As String)
    Dim loc As NativeObject
        loc = loc.Initialize(
    Dim no As NativeObject = DateTime
    "dateFormat").SetField("locale", loc)
    "timeFormat").SetField("locale", loc)
    End Sub
    and following statements in Application_Start
    SetDateTimeLocale ("de_DE")
    Log (DateTime.Date (DateTime.Now))
    Unlike I tried some id, output was the same 05/12/2019.

    Note, I use a simulator (which I erase very often). So settings are default - english; US.

    Yesterday I tried apple's samples from
    They work fine.

    BTW, DateFormat works fine, so there is a workaround anyway.
    Last edited: May 13, 2019
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice