I need to print some date on screen. Right now these are written in the good format: day month year.. But i would like the timestamp to be printed in 24 hours because it prints 10:55:00 AM when using {0:F} string format
I would like to have my date printing like this: Day Month Year 22:55:00.
Thanks
I understood what to do but actually i don't know how to do it in my case:
The date is stored in a msde database in the datatime format . I've made a formular in wich the date has to be written like this: mm/dd/yyyy if i don't want to receive an error.
When i retrieve the date in my repeater i use the classic DataBinder.Eval(container.DataItem,"date","{0:F}").
With that I don't know how to store the date in format dd/mm/yyyy and how to change it's format string when retrieving it so my date looks like: dd/mm/yyyy 14:05:00 (No PM or AM formatting)
Hi BasicDatePicker!
It was exactlly what I wanted, so thank you very much :).
I really like .Net, it's too cool to actually see how easy it is (with some help sometimes :) )
Thanks again.
None
0 Points
23 Posts
How to change just one element culture
Jul 18, 2005 09:53 AM|ddeltgen|LINK
I need to print some date on screen. Right now these are written in the good format: day month year.. But i would like the timestamp to be printed in 24 hours because it prints 10:55:00 AM when using {0:F} string format
I would like to have my date printing like this: Day Month Year 22:55:00.
Thanks
Member
50 Points
406 Posts
Re: How to change just one element culture
Jul 18, 2005 04:35 PM|BasicDatePicker|LINK
Try passing an InvariantCulture object to the .ToString() method. Example:
Response.Write(DateTime.Now.ToString("F",System.Globalization.CultureInfo.InvariantCulture));
I think the InvariantCulture will give you the expected results.
Hope this helps.
Basic Date Picker - A Quicker Picker(TM) - ASP.NET Calendar, Date and Time Web Controls
None
0 Points
23 Posts
Re: How to change just one element culture
Jul 20, 2005 09:50 AM|ddeltgen|LINK
The date is stored in a msde database in the datatime format . I've made a formular in wich the date has to be written like this: mm/dd/yyyy if i don't want to receive an error.
When i retrieve the date in my repeater i use the classic DataBinder.Eval(container.DataItem,"date","{0:F}").
With that I don't know how to store the date in format dd/mm/yyyy and how to change it's format string when retrieving it so my date looks like: dd/mm/yyyy 14:05:00 (No PM or AM formatting)
Member
50 Points
406 Posts
Re: How to change just one element culture
Jul 20, 2005 11:31 AM|BasicDatePicker|LINK
Instead of the 'F' which is a Standard Format String, you can pass a Custom Format String. Example:
DataBinder.Eval(container.DataItem,"date","{0:dd/MM/yyyy HH:mm:ss}")
The above should output "20/07/2005 21:27:48".
Hope this helps.
Basic Date Picker - A Quicker Picker(TM) - ASP.NET Calendar, Date and Time Web Controls
None
0 Points
23 Posts
Re: How to change just one element culture
Jul 21, 2005 03:05 AM|ddeltgen|LINK
It was exactlly what I wanted, so thank you very much :).
I really like .Net, it's too cool to actually see how easy it is (with some help sometimes :) )
Thanks again.