Skip to main content

TrFile_SetTimestampCreated (function reference)

By June 1, 2024June 4th, 2024Online Help, Troi File Plug-in
Troi File Plug-in > Functions reference > TrFile_SetTimestampCreated
Troi File Plug-in for FileMaker Pro

TrFile_SetTimestampCreated

Sets the creation date/time of the file specified by the filePath.

SyntaxFunction badge

TrFile_SetTimestampCreated ( switches ; filePath ; timestamp )

Parameters

switches reserved for future use, leave empty or set to "-Unused"
filePath the path to the file
timestamp new creation date/time of the file

Returned Result

Data type returned

Error code

Result

If successful it returns 0.
If unsuccessful it returns an error code starting with $$ and the error code. Returned error codes can be:

$$-43 The file was not found
$$-4241 The date/time is too big
$$-4245 The date/time is too small

Originated in

Troi File Plug-in 3.0.4

Compatibility

FileMaker Pro 17 to FileMaker Pro 21 (2024)

Considerations

– macOS limits (using file system HFS+): on macOS the minimum representable date is January 1st, 1904 GMT. The maximum representable date is February 6, 2040 at 06:28:15 GMT.
– Windows limits: the minimum representable date is January 1st, 1980. The maximum date is December 31, 2107.
– The timestamps are in local time.
– On macOS it may take some time (about 5 secs) before the change is visible in the Finder. On Windows you need to refresh a Window before you see the change.
– Some file systems may not support creation time.

Example

Set Variable [ $ErrorCode ; TrFile_SetTimestampCreated ( "-Unused" ; "C:\test.doc" ; 
				Timestamp ( Date ( 6 ; 30 ; 2020 ) ; Time ( 10 ; 59 ; 59 ) ) ) ] 

This will set the creation date/time to June 30th, 2020 at 10:59:59.

Example 2

We assume that in your FileMaker file the following fields are defined:

    gFileSpec			Global, text
    gTimestampCreated		Global, timestamp
    gErrorCode			Global, text

gFileSpec should contain the path to an existing file, for example “D:\Out.txt” (Windows) or “Mac HD:Out.txt” (Mac). gTimestampCreated should contain a valid date/time. In a script add the following script step:

Set Field [ gErrorCode ; TrFile_SetTimestampCreated ( "-Unused" ;  this::gTheFile ; this::gTimestampCreated ) ]

This will set the file’s creation date/time to the value in the timestamp field.

Used in example file

Attribute.fmp12

Related functionsFunction badge

TrFile_GetTimestampCreated
TrFile_SetTimestampModified

Related script stepScript step badge

Set Timestamp Created

Related topics

Troi File Plug-in online help (overview)


Online Help Page for Troi File Plug-in for 17 to 2024 –> TrFile_SetTimestampCreated (filep4285) 2024-0604 19:37:53