Click here to Skip to main content
12,819,950 members (29,662 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as

Stats

11.4K views
5 bookmarked
Posted 29 Mar 2012

How to get server side date time without your own server

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

Introduction

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 Google.com's Header site).

Background

I use the System.Net Namespace to do it.

Using the code

string URL = "http://www.google.com";    
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 ;-)

License

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

Share

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...

Pro
Pro

Comments and Discussions

 
Questionvote 5 Pin
beqiraj2546-Apr-12 0:04
memberbeqiraj2546-Apr-12 0: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
Web01 | 2.8.170308.1 | Last Updated 29 Mar 2012
Article Copyright 2012 by MB Seifollahi
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid