Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
152 views
in Technique[技术] by (71.8m points)

asp.net - The time format is not respected in c#

I have the following problem I am working with Microsoft.ReportViewer.WebForms Version = 10.0.0.0 in visual studio 2010 .NET 4 I am doing an attendance report

report design image

In the Value section of the field I have the following * CDate (Fields! Time1.Value) .ToString ("hh: mm tt") * I want the time to be converted to am / pm format on a windows 10 machine yes It works but when passing it to the server where the report that is a windows 2012 R2 Standard will be hosted, it does not show me that format, I attach an image of how it looks on the server

report on server

I also tried converting it to the format like this: Convert.ToDateTime (Fields! Time1.Value) .ToString ("hh: mm: ss tt") But it does not work

I checked the server time format and it is correct. registry settings

I am using IIS

cultural reference

Is there something else I need to configure or why is the format not up to me?

Upgrade:

image upgrade

error

question from:https://stackoverflow.com/questions/65602665/the-time-format-is-not-respected-in-c-sharp

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try adding CultureInfo.

date1 = new DateTime(2008, 1, 1, 18, 9, 1);
Console.WriteLine(date1.ToString("hh:mm:ss tt", 
                  CultureInfo.InvariantCulture));
// Displays 06:09:01 PM 

Source: https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-4.0/8kb3ddd4(v=vs.100)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...