---
title: "DateTime.Now in Model C# ASP.NET MVC 4"  
description: "DateTime.Now in Model C# ASP.NET MVC 4"  
author: "Anonymous User"  
published: 2014-03-06  
updated: 2014-03-06  
canonical: https://www.mindstick.com/forum/1982/datetime-now-in-model-c-sharp-asp-dot-net-mvc-4  
category: "asp.net mvc"  
tags: ["asp.net mvc"]  
reading_time: 1 minute  

---

# DateTime.Now in Model C# ASP.NET MVC 4

I have created a [model](https://yourviews.mindstick.com/view/81334/america-is-reopening-after-corona-lockdown-but-on-swedish-model) for [Articles](https://www.mindstick.com/articles/12872/how-to-write-articles-of-50-and-more-a-day-quick-and-easy), and in the articles I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to implement a date created on initial create.

//Model

[Display(Name = "Date Created")]

[public](https://www.mindstick.com/blog/11097/java-access-modifiers-the-public-and-the-private-modifiers) [DateTime](https://www.mindstick.com/forum/12949/how-to-validate-if-a-datetime-field-is-not-null-empty) dateCreated

{

get { return DateTime.Now; }

}

It works well when I create an [article](https://www.mindstick.com/articles/95867/are-you-looking-for-500-credit-score-mortgage-lenders-houston-continue-reading-this-article), but it also sets the same [date time](https://www.mindstick.com/blog/386/retrieve-sql-server-installation-date-time) [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) to all the other articles. :/

Is there a way around this?

## Replies

### Reply by Pravesh Singh

Hi Samuel,\

Here's what you need:

```
private DateTime? dateCreated;public DateTime DateCreated{    get { return
dateCreated ?? DateTime.Now; }    set { dateCreated
= value; }}
```


---

Original Source: https://www.mindstick.com/forum/1982/datetime-now-in-model-c-sharp-asp-dot-net-mvc-4

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
