Script

FTP

The professional tool to automate FTP, SFTP, FTPS

and schedule FTP batch jobs

Syntax:

GETTIME(format)

  • format(optional): The following formats are available:
    FORMAT0 YYYY_MM_DD-hh_mm_ss
    FORMAT1 DD_MM_YYYY-hh_mm
    FORMAT2 YYYY_MM_DD-hh_mm
    FORMAT3 YYYYMMDD
    FORMAT4 hhmm
    YEAR Current year in four digits format.
    MONTH Current month.
    DAY Current day.
    HOUR Current hour.
    MIN Current minute.
    SEC Current second.
    WEEKDAY Current day of week.
    Possible values are
    Sun, Mon, Tue, Wed, Thu, Fri or Sat
    (hh: Hour, mm: Minute, DD: Day, MM: Month, YYYY: Year )

Return value:

The requested date data.

Remarks:

  • The format parameter is optional, you may call GETTIME without any parameters. In this case it will default to FORMAT0.
  • For date operations the FORMAT0 (which is YYYY_MM_DD-hh_mm_ss) must be used. For further information take a look at Advanced topics and rare features, section “Operations with dates”.

Command History:

YEAR, MONTH, DAY, HOUR, MIN, SEC and WEEKDAY formats were added in ScriptFTP v2.2 Build 4th April 2006.

Examples:

# Print the current date in different formats:
PRINT(GETTIME(FORMAT1))
PRINT(GETTIME(FORMAT2))
PRINT(GETTIME(FORMAT3))
PRINT(GETTIME(FORMAT4))
 
# FORMAT1 is used by default:
PRINT(GETTIME)
 
# Get the current date
$date=GETTIME()
 
# Concatenate "BACKUP", the current date and ".txt" to build the log file name
$logfile="C:\BACKUP_LOGS\BACKUP-".$date.".txt"
 
# Start logging
LOGTO($logfile)
 
OPENHOST("ftp.host.com","myuser","mypassword")
PUTFILE("C:\PICS\*.jpg")
CLOSEHOST
# Use GETTIME and CONCAT to build custom
# date formats
$mymonth=GETTIME(MONTH)
$myyear=GETTIME(YEAR)
 
# Concatenate text
$mydate=$mymonth."-".$myyear
 
PRINT($mydate)
 
# Shorter way:
PRINT(GETTIME(MONTH)."-".GETTIME(YEAR))