C# app:how to get the current date & time of server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ssknov
    New Member
    • Dec 2007
    • 40

    C# app:how to get the current date & time of server

    hi
    i need to access the server machine's current date and time? Pls any body explain me in detail how to do this . since i am a beginner, i find it difficult to perform this.

    Help me

    thanks in advance
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    DateTime.Now will return the current date and time as an object for whatever computer the code is executed on.

    Comment

    • ssknov
      New Member
      • Dec 2007
      • 40

      #3
      Originally posted by Plater
      DateTime.Now will return the current date and time as an object for whatever computer the code is executed on.

      hi plater
      thank u for ur reply,

      but i need to know how to get the server machines from client machine.
      ie . code to access the servers datetime from client machine.
      can u help me
      thanks in advance
      kssk

      Comment

      • baburk
        New Member
        • Oct 2006
        • 111

        #4
        The below line give you the server time and date

        System.DateTime .Now.ToLongTime String();

        Try this and reply

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          Well you might need to be more specific.
          If the computer has the timeofday service running, your can make a special socket connection to it and get the date and time on the server.
          If you are creating the application that runs on the server you can make a special message sequence that would have the server reply with it's time.

          Please explain the details or your client/server relationship.

          Comment

          Working...