我想显示本地系统日期时间格式在服务器上的日期,但它采取的服务器日期时间格式的本地系统日期时间格式。在localhost运行时运行良好,但在服务器运行时,格式为MM/dd/yyyy(US格式),与系统日期时间格式无关。我已经尝试过这些但没有想要的结果C#:在服务器
string DateTimeFormat = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern
System.Threading.Thread threadForCulture = new System.Threading.Thread(delegate() { });
string DateTimeFormat = threadForCulture.CurrentCulture.DateTimeFormat.ShortDatePattern;
有没有其他方法可以实现这个目标?
可以使用dt.ToString( “DD/MM/YYYY”);这将日期对象(dt)转换为dd/MM/yyyy格式。 –
@SouvikGhosh,我不想要特定的格式。它必须按照本地系统日期时间格式进行更改,并在本地格式更改时进行更改 – Sanjay