2

Am using DateTime.Now.ToString("MM/dd/yyyy"); to get the current date. If i change the system date the date returned by DateTime.Now() also changes which is vulnerable.

Any one has a solution for this? Thanks

Anjana
  • 1,447
  • 5
  • 23
  • 33

3 Answers3

2

You would have to use a NTP server to retrieve the current date/time in that case. Look at an implementation posted in another question. How to Query an NTP Server using C#?

Community
  • 1
  • 1
kfuglsang
  • 2,385
  • 2
  • 21
  • 26
1

When you don't trust the time of the machine you can use an NTP (Network Time Protocol) client call to ask a trusted time server for the correct time.

There are many client codes. For example http://www.dotnet-snippets.com/dns/c-simple-network-time-ntp-protocol-client-SID571.aspx

Johan Lundberg
  • 26,184
  • 12
  • 71
  • 97
0

Hai all thanks for the comments and gateways.

I would like to share one link which helped me.

http://nickstips.wordpress.com/2010/02/12/c-get-nist-internet-time/

Anjana
  • 1,447
  • 5
  • 23
  • 33