Ghazanfar Khan
Ghazanfar Khan

Reputation: 3718

Convert DatePicker Value to String in windows store app

I have converted date picker values to string like this

BookingDate = date.Date.ToString();

but its gives value like this 18-Aug-14 3:21:01 PM -07:00 . I only want in this format 18/8/14 , How to do this?

Upvotes: 0

Views: 1218

Answers (1)

Soner Gönül
Soner Gönül

Reputation: 98840

You can format your DateTime like;

date.Date.ToString(@"dd\/M\/yy");

or

date.Date.ToString("dd'/'M'/'yy");

And I don't believe DateTime.Date property returns PM -07:00 as an hour because from documentation;

A new object with the same date as this instance, and the time value set to 12:00:00 midnight (00:00:00).

Upvotes: 1

Related Questions