Script

FTP

The professional tool to automate FTP, SFTP, FTPS

and schedule FTP batch jobs

MENUMENU

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 in numerical format
    DAY Current day in numerical format
    HOUR Current hour
    MIN Current minut
    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))
# Calculate the month name based on the month number
$month_number = GETTIME(MONTH)
IF($month_number=="1")
   $month_name = "JAN"
END IF
IF($month_number=="2")
   $month_name = "FEB"
END IF
IF($month_number=="3")
   $month_name = "APR"
END IF
IF($month_number=="4")
   $month_name = "MAY"
END IF
IF($month_number=="5")
   $month_name = "JUN"
END IF
IF($month_number=="6")
   $month_name = "JUL"
END IF
IF($month_number=="7")
   $month_name = "AUG"
END IF
IF($month_number=="8")
   $month_name = "SEP"
END IF
IF($month_number=="10")
   $month_name = "OCT"
END IF
IF($month_number=="11")
   $month_name = "NOV"
END IF
IF($month_number=="12")
   $month_name = "DEC"
END IF
 
 
PRINT("The current month name is: ".$month_name)