Click here to Skip to main content
13,191,400 members (61,568 online)
Click here to Skip to main content
Add your own
alternative version


5 bookmarked
Posted 29 Mar 2012

How to get server side date time without your own server

, 29 Mar 2012
Rate this:
Please Sign up or sign in to vote.
How to get server side date-time in your Windows Application for free.


Sometimes we want to get server side date-time but we do not have our server to do it. This article teaches you how you can do this (I use's Header site).


I use the System.Net Namespace to do it.

Using the code

string URL = "";    
System.Net.HttpWebRequest rq2 = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(URL);
System.Net.HttpWebResponse res2 = (System.Net.HttpWebResponse)rq2.GetResponse();
DateTime Date = DateTime.Parse(res2.Headers["Date"]); 

Now , you can get server side date and time in your DateTime variable.

Enjoy ;-)


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

MB Seifollahi
Software Developer 1
Iran (Islamic Republic of) Iran (Islamic Republic of)
No Biography provided

You may also be interested in...


Comments and Discussions

Questionvote 5 Pin
beqiraj2545-Apr-12 23:04
memberbeqiraj2545-Apr-12 23:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171017.1 | Last Updated 29 Mar 2012
Article Copyright 2012 by MB Seifollahi
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid