Simsons
Simsons

Reputation: 12745

How to remove mili seconds from '0' date formatting

I am trying to convert the DateTime to following Format.

2015-05-30T12:00:00+05:30

When I am trying with 'o' formatter getting the out put in following format,

string plannedStartTime = startTime.ToString("o");

output:2015-06-12T16:54:47.3206929+05:30

I need to remove the mil seconds from that .

Not getting any formatters from MSDN

Any other Formatters?

Upvotes: 1

Views: 61

Answers (1)

Bas
Bas

Reputation: 27105

You can use a custom formatter:

string plannedStartTime = startTime.ToString("yyyy-MM-ddTHH:mm:sszzz");

See also Custom Date and Time Format Strings

Upvotes: 5

Related Questions