Simon Farrow
Simon Farrow

Reputation: 1921

Pretty printing of DateTime values in C#

I'm hoping that someone has found a way of doing this already or that there is a library already in existence. It's one of those things that would be nice but is in no way necessary for the time being.

The functionality I'm looking for is something like datejs in reverse.

Thanks,

Simon.


Thanks, using something like the dddd example might be a good start towards usability. The more I think about this problem the more it depends on the values being used. I'm specifically dealing with a series of timestamped versions of a document so there is a good chance that they will be clustered. Today isn't so hot if you have saved it three times in the last five minutes.

If I come up with something I'll share it with the community.

Upvotes: 5

Views: 9297

Answers (2)

James Curran
James Curran

Reputation: 103535

Actually, what you really want is the Custom DateTime Format strings: http://msdn.microsoft.com/en-us/library/8kb3ddd4(VS.71).aspx

DateTime.Now.ToString("ggyyyy$dd-MMM (dddd)")

will return "A.D.2008$06-Nov (Thursday)" if that's what you want.

And to get something closr to datejs ("in forward"), you can use the same strings in DateTime.ParseExact()

Upvotes: 9

mmiika
mmiika

Reputation: 10360

http://msdn.microsoft.com/en-us/library/az4se3k1(VS.71).aspx should get you on your way,

Upvotes: 0

Related Questions