Get Server's Time() and Date()

This forum is for ideas and or code to be contributed for general use.
Post Reply
Message
Author
User avatar
GeneB
Posts: 158
Joined: Sun Jan 31, 2010 8:32 am
Location: Albuquerque, New Mexico, USA
Contact:

Get Server's Time() and Date()

#1 Post by GeneB »

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}


User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

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

#2 Post by rdonnay »

Thanks Gene.

We all appreciate user contributions like this.
The eXpress train is coming - and it has more cars.

Post Reply