Bug 31457 - Datetime wrong format
Summary: Datetime wrong format
Status: RESOLVED ANSWERED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: XI 8.10
Hardware: Other Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-06-29 07:25 UTC by Kejvi
Modified: 2015-06-29 07:37 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Screenshot (28.39 KB, image/png)
2015-06-29 07:26 UTC, Kejvi
Details
Screenshot (27.12 KB, image/png)
2015-06-29 07:26 UTC, Kejvi
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Kejvi 2015-06-29 07:25:02 UTC
I am working on an financial application for iPhone and iPad. I am having a issue with the date format. I works different in different versions of OS.

I have a very trivial code that gets the current date separated by slashes "/"

iOS 8.1 or older 

 private string endDate=System.DateTime.Today.Date.ToString("dd/MM/yyyy");

 what I get is the current date formatted in the right format "29/06/2015"

iOS 8.2 or higher (8.3)

 private string endDate=System.DateTime.Today.Date.ToString("dd/MM/yyyy");
 
 what I get is the current date but is not formated in the right way , "29.06.2015"

I don't know if this is something that should be handled by Xamarin or I have to check 
by my selfe the version of iOS and construct a valid date. This is a big problem in my
point of view because if for every change on iOS version I have to check all the primitive
types is a big problem.

I hope you will fix this problem in later releases.
Comment 1 Kejvi 2015-06-29 07:26:21 UTC
Created attachment 11761 [details]
Screenshot
Comment 2 Kejvi 2015-06-29 07:26:58 UTC
Created attachment 11762 [details]
Screenshot
Comment 3 Rolf Bjarne Kvinge [MSFT] 2015-06-29 07:37:18 UTC
This depends on the culture of the executing thread (System.Threading.Thread.CurrentThread.CurrentCulture).

See this for more information: https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx#dateSeparator

If the date string must be using slashes, you must escape them:

> private string endDate=System.DateTime.Today.Date.ToString("dd\\/MM\\/yyyy");