Get Server's Time() and Date()

This forum is for ideas and or code to be contributed for general use.

Get Server's Time() and Date()

Postby GeneB » Tue Jul 06, 2010 7:59 pm

Since the stations on our network occassionally have their time and date changed by a user, we had a need to get the time() and date() from the server for time stamping documents. A simple way to do it: create a file on the server, extract its time and date, erase the file.

Hope someone finds this useful.

GeneB in Albuquerque


Code: Select all
FUNCTION ServerTimeDate()
local  cTime,dDate, nHandle, aDirectory

// requires  Directry.ch
// DataPath() stores the path to the dbf files on the server
// file gets creation time and date from the server it resides on, DataPath()

FERASE( DataPath() + "\timefile.txt" )
nHandle := FCreate(DataPath() + "\timefile.txt")

// get the file's date and time
IF nHandle > 0
   aDirectory := DIRECTORY ( DataPath() + "\timefile.txt" )
   dDate := aDirectory[1,F_CREATION_DATE]
   cTime := aDirectory[1,F_CREATION_TIME]
ELSE
   dDate := DATE()
   cTime := TIME()
ENDIF

FCLOSE(nHandle)
FERASE( DataPath() + "\timefile.txt" )

RETURN {cTime,dDate}

GeneB
 
Posts: 19
Joined: Sun Jan 31, 2010 3:32 pm
Location: Albuquerque, New Mexico, USA

Re: Get Server's Time() and Date()

Postby rdonnay » Wed Jul 07, 2010 3:48 pm

Thanks Gene.

We all appreciate user contributions like this.
The eXpress train is coming - and it has more cars.
User avatar
rdonnay
Site Admin
 
Posts: 422
Joined: Thu Jan 28, 2010 1:58 am
Location: Boise, Idaho USA


Return to User Contributions

Who is online

Users browsing this forum: No registered users and 1 guest