Home Website date format changes after uploading even though cultures are set globally
Reply: 0

Website date format changes after uploading even though cultures are set globally

user5840 Published in September 20, 2018, 12:55 pm

I have created a form that uses a bootstrap datepicker to allow the user to input the date, and the methods used work perfectly when testing on my localhost. A problem occurred when i uploaded the site to do a final test which switches the date format throughout my site from dd/MM/yyyy to dd-MM-yyyy even though i have converted the date using global.asax culture settings. This date format wouldn't be such an issue but my forms no longer submit and the error i get says "sequence contains no elements" I have checked all settings on both the server and in the site that could be causing this but cannot seem to fix the issue. Thanks in advance for any suggestions.

Convert the date to the specified format on the front end:


Global.asax code:

protected void Application_Start()
    CultureInfo newCulture = new CultureInfo("en-ZA");
    newCulture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
    newCulture.DateTimeFormat.DateSeparator = "/";
    Thread.CurrentThread.CurrentCulture = newCulture;
    Thread.CurrentThread.CurrentUICulture = newCulture;

Controller Code:

_vehicle[c] = new Vehicle()
    inceptionDate = string.IsNullOrEmpty(frm["inception_" + c]) ? 
    (IsFleetClient ? DateTime.Now.Date.AddDays(1) : DateTime.Now.Date) : 
    Convert.ToDateTime(frm["inception_" + c]).ToLocalTime()
share|improve this question

1 Answer 1

active oldest votes
up vote 0 down vote accepted
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.571719 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO