Skip to content

Timezone Conversion

Robin Rodricks edited this page Nov 30, 2024 · 19 revisions

API

Settings

  • Config.TimeConversion - Server timestamps are converted into the given timezone. You need to set the other properties for this to work. Default: FtpDate.ServerTime.

    • FtpDate.ServerTime will return the original timestamp.
    • FtpDate.LocalTime will convert the timestamp into your local machine's timezone.
    • FtpDate.UTC will convert the timestamp into UTC format (GMT+0).
  • Config.ServerTimeZone - The timezone of the FTP server. If the server is in Tokyo and returns Tokyo timestamps, set this to Toyko. If the server returns timestamps in UTC then keep this as UTC. Default: UTC

  • Config.ClientTimeZone - The timezone of your machine. If your machine is in Paris, then set this to Paris. If your machine is synchronized with UTC then keep this as UTC. Default: <local machine's timezone>

Utilities

  • Config.SetServerTimeZone() - Allows you to easily set the server timezone across any OS by providing the Windows and Unix timezone names.

  • Config.SetClientTimeZone() - Allows you to easily set the client timezone across any OS by providing the Windows and Unix timezone names.

  • client.ConvertDate() - Main method used to translate local dates to server dates. Typically converts the date provided by the FTP server into the timezone required locally. If reverse is true, converts the local timezone date into the date required by the FTP server. In most cases you will never need to use this directly.

FAQs

How do I retrieve date/time values in UTC?

Set the server's timezone into ServerTimeZone and then set TimeConversion = FtpDate.UTC

How do I retrieve date/time values in my local timezone?

Set the server's timezone into ServerTimeZone and then set TimeConversion = FtpDate.LocalTime

Also set ClientTimeZone with the timezone of your machine.

Clone this wiki locally