Time error in asp.net c #

The time-based time format works fine when it is running on the local server, but the same one does not work fine when it is uploaded to the server.

in localhost

02-02-2014

on server

2-2-2014

I want the localhost format on the server as well

+3
source share
2 answers

You should provide sample code to help you determine the context. But keeping things as simple as possible ...

A date is a date, regardless of the host computer and its locale, so if you want to ignore the localization of the host computer, which affects things like, for example, dates, you can consider using a custom date format.

// Display the date using a custom date format
DateTime thisDate = new DateTime(2008, 3, 15);
Console.WriteLine(thisDate.ToString("dd-MM-yyyy"));  // Displays 15-03-2008
Console.WriteLine(thisDate.ToString("dd MMM yyyy")); // Displays 15 Mar 2008
0
source

Maybe your date formatting is not the same

DateTime time = new DateTime(2014, 02, 02);

string format = "mm-dd-yy";
Console.WriteLine(time.ToString(format)); //00-02-14

format = "M-d-yy";  
Console.WriteLine(time.ToString(format)); //2-2-14
0

All Articles