Time formatting

Dear All,

I had the following code whereby I would like to get the time every 15 mins later.

DateTime now = DateTime.Now;

string today = now.ToString("yyyy/MM/dd hh:mm:ss");

txtNow.Text = today;

string fifteenminslater = now.AddMinutes(15).ToString("yyyy/MM/dd hh:mm:ss");

txt15minslater.Text = fifteenminslater;

I had tried this and when I set the time to '2006/02/28 11:58:02' which is PM(afternoon).

After 15 mins later, the result show '2006/03/01 12:13:02'

whereby my desired result should be '2006/03/01 00:13:02'.

Can anyone please help

Thanks



Answer this question

Time formatting

  • MladenP

    Use "HH" instead of "hh".

  • Time formatting