The Darkness Behind DateTime.Now
page 1 of 7
Published: 31 May 2011
Unedited - Community Contributed
Abstract
DateTime.Now is one of the commonly-used properties in the .NET Framework in the majority of applications designed. Although this property is designed to serve for particular purposes, the lack of understanding and training has driven many .NET developers to use it in wrong circumstances where other options like DateTime.UtcNow property and Stopwatch class should be used and are recommended. In this article we discuss these three options along with the main applications of each, and provide a quantitative comparison between them to show why DateTime.Now is expensive and should not be misused in many cases.
by Keyvan Nayyeri
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 38251/ 96

Introduction

Although there has been an incredible development for the .NET Framework in the past decade and many technologies and tools are added to enhance the programming experience for software developers, still there are some basic facts about .NET programming that are not taught well and have had an important impact on the performance of .NET applications written around the world and deployed in different scales.

One of these mistakes that has been common among many developers is the misuse of DateTime.Now property that is designed for particular purposes but is used widely in circumstances where DateTime.UtcNow property or Stopwatch class are recommended.

In this article we discover three options for working with DateTime values in the .NET Framework in order to clarify their internal workings, and where and when they should be used, and then we discover a quantitative comparison between these options to see why the use of DateTime.Now should be restricted.


View Entire Article

User Comments

Title: 你们不能明白   
Name: 巴拿马
Date: 2012-12-08 3:41:36 AM
Comment:
巴拿马






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-10-13 12:41:52 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search