[Solved] Date format working locally error after publishing on IIS

Last Reply 15 days ago By trisetia302

Posted 15 days ago

Hi Guys,

I'm get trouble when project finished and publish on IIS server. The trouble is Date Format can change itself after it is run on IIS Server. - Format Date in Database is 2021-09-05 (yyyy-MM-dd) (year-month-date)

After project publish on IIS server the Date Format is - Format Date in IIS Server is (09-05-2021) (MM-dd-yyyy)(month-date-year). This is invalid date format in Indonesian.

I have try to format that date format using string.format() in code behind.cs like this below.

txttgl_jatuh_tempo.Text = string.Format("{0:dd-MM-yyyy}", rdr["tanggal_jatuh_tempo"].ToString()); 

The code above is working properly when deployed on visual studio and get correct result of date format, but after project completed and deployed/running on IIS server the date format was change itself with this date format (09-05-2021) (MM-dd-yyyy)(month-date-year).

Of course this this date format make user confused because correct Indonesian date format is (date-month-years) (dd-MM-yyyy).

Any help could be appriciate.

You are viewing reply posted by: trisetia302 15 days ago.
Posted 15 days ago

@Andrea

@dharmendr

Alhamdulilah, Problem Solved Sir.

Thanks so much for the help.

This code working properly sir.

DateTime tglJatuhTempo = Convert.ToDateTime(rdr["tanggal_jatuh_tempo"].ToString());
txttgl_jatuh_tempo.Text = string.Format("{0:dd/MM/yyyy}", tglJatuhTempo);