How to change just one element culture RRS feed

  • Question

  • User-533181614 posted
    Hi !

    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.

    Monday, July 18, 2005 9:53 AM

All replies

  • User1471551714 posted
    Hi ddeltgen,

    Try passing an InvariantCulture object to the .ToString() method. Example:


    I think the InvariantCulture will give you the expected results.

    Hope this helps.
    Monday, July 18, 2005 4:35 PM
  • User-533181614 posted
    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)

    Wednesday, July 20, 2005 9:50 AM
  • User1471551714 posted
    Hi ddeltgen,

    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.
    Wednesday, July 20, 2005 11:31 AM
  • User-533181614 posted
    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.
    Thursday, July 21, 2005 3:05 AM