Wilson WindowWare Tech Support

WinBatch WinBatch+Compiler WebBatch
Home | Tech Database | Tech BBS | White Papers | Purchase


How to Get Server Time and Date

Keywords: server time	

Question:

I am trying to get the current time and date from the server and not the user computer. My EXE is on the server, but it is executed by a local program.

Answer:

See the Win32 Network Extender functions : w9xRemoteTime and wntRemoteTime.


*OR*

If you are running TCP/IP on the server, you might be able to use the WinSock Internet extender to query the datetime port. Ummm something like...

AddExtender("wwwsk34I.dll")
   talksocket=SOpen()
   yyy=wxGetLastErr()
   Terminate(yyy!=0,"Sopen",yyy)
   ret=SConnect(talksocket,"muss.cis.mcmaster.ca","daytime")
   yyy=wxGetLastErr()
   Terminate(yyy!=0,"Sconnect",yyy)
   xxx=sRecvLine(talksocket,555)
   sClose(talksocket)
   Message("daytime",xxx)

	;The following should be used WITH EXTREME CAUTION to set the time on Y2K!!! 
	;It could has disasterous consequences if (1) the server is not "daytime" served, in other
	;words, the simple network protocol, daytime, must be set on the server.  This protocol allows a
   ;Windows NT computer to respond to requests from other systems that support the daytime protocol. 
	;(2) if a zillion different PCs are trying to run it on Y2K, (3) probably not a good idea
	;to try to automate such a thing anyway, but here 'tis for the brave and not faint hearted:

	a=ItemExtract(4,xxx," ")
	hour=ItemExtract(1,a,":")
	minute=ItemExtract(2,a,":")
	seconds=ItemExtract(3,a,":")

	Message(hour, "%minute%%@crlf%%seconds%")

	year=2000
	month=01
	day=01

	Intcontrol(58, strcat(year,":",month,":",day,":",hour,":",minute,":",seconds),0,0,0)


Other Possibilities:

In Novell to set time:
  1. Set server time in hardware on the server.

  2. Change server time subsequently from client using FCONSOLE utility in netware public directory on server.

  3. To get exact time from National Bureau of Standards:

    DOS programs: PCK300.zip, Time_s.zip, Tset72.zip, timesy.zip all in the IBMSYS forum in section 1.

    Windows programs: SetTm1.zip in WinShare forum, section 3.

In other operating systems:
  1. Follow the Novell procedure to set server time correctly. Even in a peer to peer network like Lantastic, one workstation client will have to be the time server.

  2. As part of the network setup from DOS, include a command to set workstation time to server time. All professional networks allow this."

Article ID:   W13873
Filename:   How to Get Server Time.txt