Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6165751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:13:13+00:00 2026-05-23T22:13:13+00:00

how can i get current time From Internet (External Resource – Not From Server)?

  • 0

how can i get current time From Internet (External Resource – Not From Server)?
Edited
For Example From the Below WebSite :
http://www.timeanddate.com/worldclock
Reason
i will redirect my pages to a Lock page after one month (by checking DateTime.Now) and in that page user should input activation code for comming back…
for some security reasons i want to get the current Date/Time From Out Of My Server…

thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:13:14+00:00Added an answer on May 23, 2026 at 10:13 pm

    I think this will help you out of it.Apply the below mentioned code for retrieving the date from Internet.

    public static DateTime GetFastestNISTDate()
    {
        var result = DateTime.MinValue;
    
        // Initialize the list of NIST time servers
        // http://tf.nist.gov/tf-cgi/servers.cgi
        string[] servers = new string[] {
            "nist1-ny.ustiming.org",
            "nist1-nj.ustiming.org",
            "nist1-pa.ustiming.org",
            "time-a.nist.gov",
            "time-b.nist.gov",
            "nist1.aol-va.symmetricom.com",
            "nist1.columbiacountyga.gov",
            "nist1-chi.ustiming.org",
            "nist.expertsmi.com",
            "nist.netservicesgroup.com"
    };
    
            // Try 5 servers in random order to spread the load
            Random rnd = new Random();
            foreach (string server in servers.OrderBy(s => rnd.NextDouble()).Take(5))
            {
                try
                {
                    // Connect to the server (at port 13) and get the response
                    string serverResponse = string.Empty;
                    using (var reader = new StreamReader(new System.Net.Sockets.TcpClient(server, 13).GetStream()))
                    {
                        serverResponse = reader.ReadToEnd();
                    }
    
                    // If a response was received
                    if (!string.IsNullOrEmpty(serverResponse))
                    {
                        // Split the response string ("55596 11-02-14 13:54:11 00 0 0 478.1 UTC(NIST) *")
                        string[] tokens = serverResponse.Split(' ');
    
                        // Check the number of tokens
                        if (tokens.Length >= 6)
                        {
                            // Check the health status
                            string health = tokens[5];
                            if (health == "0")
                            {
                                // Get date and time parts from the server response
                                string[] dateParts = tokens[1].Split('-');
                                string[] timeParts = tokens[2].Split(':');
    
                                // Create a DateTime instance
                                DateTime utcDateTime = new DateTime(
                                    Convert.ToInt32(dateParts[0]) + 2000,
                                    Convert.ToInt32(dateParts[1]), Convert.ToInt32(dateParts[2]),
                                    Convert.ToInt32(timeParts[0]), Convert.ToInt32(timeParts[1]),
                                    Convert.ToInt32(timeParts[2]));
    
                                // Convert received (UTC) DateTime value to the local timezone
                                result = utcDateTime.ToLocalTime();
    
                                return result;
                                // Response successfully received; exit the loop
    
                            }
                        }
    
                    }
    
                }
                catch
                {
                    // Ignore exception and try the next server
                }
            }
            return result;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My Android app requires to get the current date and time from Internet .
A two-part question: What is the best way to get the current time from
I want to get time from database then use it to compare with current
How can I get the value (string) of the current selection in a combobox?
I can get easily see what projects and dlls a single project references from
I can get the executable location from the process, how do I get the
I can get the element like this $(#txtEmail) but I'm not sure how to
I can get a list of running threads from Process.GetCurrentProcess().Threads, but I need to
I am trying to get the current time of a running animation but I
I need to compare a MySQL datetime with the current time, to get the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.