ASP.NET MVC date string slash being converted to dash in Safari input fields -


i outputting datetime string format of mm/dd/yyyy text input field. works fine on browsers except latest version of safari (on yosemite, if matters). see examples below:

this code:

      <div><input type="text" value='@model.arrival.value.tostring("mm/dd/yyyy")' /></div>   <div><input type="text" value="@html.raw(model.arrivaldatestring)" /></div>   <div><input type="text" value="8/23/2015" /></div>   <div><input type="text" value="08/23/2015" /></div> 

produces this:

screenshot

the test page setup has absolutely nothing else running on it. it's bare bones html page server side output view model. mvc 5 , .net framework 4.5.1

viewing page source, looks in safari:

<input type="text" value="08-20-2015" /> 

on other browsers, this:

<input type="text" value="08/20/2015" /> 
  • update: looks .net choosing different culture / format safari browsers. possible fix specify format provider.

i able fix issue specifying culture string format. ie.:

datetime arrival = datetime.now; cultureinfo invariant = cultureinfo.invariantculture; string datestring = arrival.tostring("mm/dd/yyyy", invariant); 

en-us works well. still not sure why happens. looks asp.net doing different based on user agent. request headers otherwise looks same.

i would've figured out earlier if able browserstack work locally.


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -