locked
convert time format RRS feed

  • Question

  • User1248258412 posted

    Hi, currently the data save in database was in format as '02/13/2016 12:53:02 AM'

    I was successful convert it to become '2016/02/13 12:53' by using 'yyyy/MM/dd HH:MI' but this was wrongly show the time, it doesn't convert the time

    eg: 12:53:02 AM should converted as 00:53 instead of 12:53

    12:23:02 PM then should be converted as 12:23

    Do anyone know how to convert for the AM and PM time to 24hours format?

    Thanks.

    Friday, March 4, 2016 2:56 AM

All replies

  • User2103319870 posted

    eg: 12:53:02 AM should converted as 00:53 instead of 12:53

    12:23:02 PM then should be converted as 12:23

    Do anyone know how to convert for the AM and PM time to 24hours format?

    Try changing your date format like below

    yyyy/MM/dd HH:mm

    Note that the last minutes I used small letter mm,

    Sample Code

    Convert.ToDateTime(datevalue).ToString("yyyy/MM/dd HH:mm")
    Friday, March 4, 2016 3:33 AM