YoTo Blog

C# DateTime -> String conversion


Getting started

This is a sample that converts DateTime to string.

namespace

System


Method

ToString

It's simple. Just pass the date format as a parameter to ToString.

var now = DateTime.Now;
var str = now.ToString("yyyy-MM-dd HH:mm:ss");

Date format notation

Date format
Refer to the above post.


Related Articles

DateTime -> String
String -> DateTime


Conclusion

Converting strings is very simple.