Boost Your .NET Projects with Spargine: Simplify Date & Time Formatting with DateTimeFormat

Spargine is a collection of open-source assemblies and NuGet packages designed for .NET 10, which I have been developing and maintaining since the release of .NET Framework 2. These assemblies are not only a core part of my projects but are also actively deployed in production environments across several companies I collaborate with.

Get Spargine

You can access the source code and NuGet packages here:

If you’ve been developing with .NET as long as I have—since Beta 1!—you know the struggle: every time you want to display a date and time in a specific format, you end up Googling or digging through documentation to get the format string just right. Sound familiar?

That’s exactly why I created the DateTimeFormat type in Spargine. Now I never have to remember those format strings again—and neither do you.

You’ll find DateTimeFormat in the DotNetTips.Spargine.Extensions project and NuGet package. It leverages the Enumeration base type (also in Spargine) to give you a clean, strongly typed set of date and time format options.

What’s Inside DateTimeFormat

Here are the built-in formatting options available:

  • FullDateLongTime – Monday, December 21, 2025 3:16:12 PM
  • FullDateShortTime – Monday, December 21, 2025 3:16 PM
  • FullDateTime – Monday, December 21, 2025 3:16 PM
  • GeneralDateLongTime – 2/21/2025 3:16:12 PM
  • GeneralDateShortTime – 12/21/2025 3:16 PM
  • LongDate – Monday, December 21, 2025
  • LongTime – 3:16:12 PM
  • MonthDay – December 21
  • MonthYear – December 2025
  • RFC1123 – Mon, 21 Dec 2025 15:16:12 GMT
  • RoundTripDateTime – 2025-12-21T15:16:12.2487693-08:00
  • ShortDate – 12/21/2025
  • ShortTime – 3:16 PM
  • SortableDateTime – 2025-12-21T15:16:12
  • UniversalFullDateTime – Monday, December 21, 2025 11:16:12 PM

Example Usage

Here’s how simple formatting becomes with Spargine:

Using the Extension Method

var result = DateTime.Now.ToFormattedString(DateTimeFormat.GeneralDateShortTime);

Or Using ToString() Directly

var result = DateTime.Now.ToString(DateTimeFormat.FullDateLongTime.DisplayName);

No memorization. No copy-paste from Stack Overflow. Just clean, reliable formatting.

Why Use DateTimeFormat

  • Strongly typed format options
  • Reduces repetitive boilerplate
  • Works seamlessly with ToFormattedString()

Summary

The next time your .NET project needs to display dates and times, skip the formatting headaches. Reach for DateTimeFormat and the ToFormattedString() extension method in Spargine—it’s fast, consistent, and engineered to save you time.

You can grab it via NuGet under DotNetTips.Spargine.Extensions.

Get Involved!

The success of open-source projects like Spargine relies on community contributions. If you find these updates useful or have ideas for further improvements, I encourage you to contribute by:

  • Submitting pull requests
  • Reporting issues
  • Suggesting new features

Your input is invaluable in making Spargine an even more powerful tool for the .NET community.

If you are interested in contributing or have any questions, feel free to contact me via email at dotnetdave@live.com. Your support and collaboration are greatly appreciated!

Thank you, and happy coding!

Pick up any books by David McCarter by going to Amazon.com: http://bit.ly/RockYourCodeBooks

One-Time
Monthly
Yearly

Make a one-time donation

Make a monthly donation

Make a yearly donation

Choose an amount

$5.00
$15.00
$100.00
$5.00
$15.00
$100.00
$5.00
$15.00
$100.00

Or enter a custom amount

$

Your contribution is appreciated.

Your contribution is appreciated.

Your contribution is appreciated.

DonateDonate monthlyDonate yearly

If you liked this article, please buy David a cup of Coffee by going here: https://www.buymeacoffee.com/dotnetdave

© The information in this article is copywritten and cannot be preproduced in any way without express permission from David McCarter.


Discover more from dotNetTips.com

Subscribe to get the latest posts sent to your email.

One thought on “Boost Your .NET Projects with Spargine: Simplify Date & Time Formatting with DateTimeFormat

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.