- Home [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
- Getting started
- Use cases
-
API
- Object types
-
Data types
- AccountType
- DynamicFieldType
- EmailType
- OrganisationStructureItemType
- PhoneType
- ReplacementType
- ServiceStatus
- UserStatus
- WatermarkPages
- WatermarkPosition
- AccountFieldTyped
- AccountFieldVoid
- ApplicationField
- Cell
- ClientEventField
- CookieOptions
- DatetimeFieldData
- DynamicBindingField
- DynamicBindingFields
- EnumField
- ErrorArgs
- ErrorObject
- FileField
- FloatFieldData
- GroupStatusField
- HttpResponse
- ImageField
- Language
- MailMessageAddress
- MailMessageAttachment
- MoneyFieldData
- Navigator
- Page
- ParseSpreadsheetOptions
- ParseSpreadsheetResponse
- RefItem
- ReportField
- ReportRef
- Role
- RoleField
- Row
- ServiceStatusInfo
- StaticApplicationFieldData
- StatusField
- TAccount
- TClientEvent
- TDate
- TDatetime
- TDuration
- TEmail
- TEnum
- TFullName
- TMoney
- TPhone
- TReport
- TStatus
- TTable
- TTime
- TTimezone
- TTimezones
- TableField
- UserField
- UserFieldData
- ValidationResult
- Watermark
- WidgetRefWithValues
- ReplacementTypeEnumBase
- RoleType
- TApplication
- TBoolean
- TCategory
- TFile
- TFloat
- TImage
- TJSON
- TLink
- TOAuth2
- TRole
- TString
- TUser
- Global constants
- Work with apps
- Web requests
- Access permissions
- Document flow
- Live Chats
- “Code” widget
- Signatures
- Business calendars
- Integration with IP telephony
- Integration with email marketing services
Date and time
Important: to initialize
Datetime
avoid using the JavaScriptDate
object. Constructors:new Datetime(value: string, format?: string): TDatetime; new Datetime(value: number) : TDatetime; new Datetime(year: number, month: number, day?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): TDatetime;
Examples of creating datetime objects:
const now = new Datetime(); const datetime1 = new Datetime(2022, 2, 24, 9, 0, 0, 0); const datetime2 = new Datetime(1645686000); const datetime3 = new Datetime('2022-02-24'); const datetime4 = new Datetime('2022-02-24T00:00:00.000Z'); const datetime5 = new Datetime('24.02.2022', 'DD.MM.YYYY');
If the date is provided as a string in the constructor and no format is specified, the value is checked against the default format
YYYY-MM-DDTHH:mm:ss.SSSZ
.Thus, you can specify values like:
To ensure all calculations in the script are performed in the user's time zone, explicitly set the current time zone:const now = new Datetime(); const yesterday = now.addDate(0, 0, -1); now. after(yesterday) // true
// Get the user for calculations const user = ...; // Set the time zone for all further calculations in the script System.timezones.current = user.timezone; const today_22_00 = Context.data. datavremya.getDate().asDatetime(new TTime(22, 0, 0, 0));
Hierarchy
Properties
Readonly day
Day of the month (1-31).
Readonly hours
Hours (0-23).
Readonly milliseconds
Milliseconds (0-999).
Readonly minutes
Minutes (0-59).
Readonly month
Month (1-12).
Readonly seconds
Seconds (0-59).
Readonly year
Year.
Methods
add
Add a duration.
Parameters
duration: TDuration
Returns TDatetime
addDate
Add days, months, or years.
Parameters
years: number
month: number
days: number
Returns TDatetime
after
Checks whether the current date is later than
date
.Parameters
date: TDatetime
Returns boolean
afterOrEqual
Checks whether the current date is the same as or later than
date
.Example:
const startDatetime = new Datetime(); const endDatetime = (new Datetime()).addDate(0, 0, 1); const beforeOrEqual = startDatetime.afterOrEqual(endDatetime); // false
Parameters
date: TDatetime
Returns boolean
asDate
Converting to the standard
Date
type.Returns Date
before
Checks whether the current date is earlier than
date
.Parameters
date: TDatetime
Returns boolean
beforeOrEqual
Checks whether the current date is the same as or earlier than
date
.Example:
const startDatetime = new Datetime(); const endDatetime = (new Datetime()).addDate(0, 0, 1); const beforeOrEqual = startDatetime.beforeOrEqual(endDatetime); // true
Parameters
date: TDatetime
Returns boolean
equal
Checks whether two objects have the same value.
Parameters
date: TDatetime
Returns boolean
format
Converting to a string of a specific format.
Here the [moment.format() syntax](https://momentjs.com/docs/#/displaying/ format/) is used. Example:
const datetime = new Datetime(); datetime.format(); // '2022-02-24T09:00:00+02:00' (ISO 8601 standard) datetime.format('dddd, MMMM Do YYYY, h:mm:ss a'); // 'Thursday, February 24th 2022, 9:00:00 am' datetime .format('ddd, h A'); // 'Thu, 9AM' datetime.format('[ Today is] dddd'); // 'Today is Thursday'
Parameters
Optional format: undefined | string
Returns string
getDate
Get date.
Returns the date in the specified time zone or in the current one if the time zone is not specified (by default, the company’s time zone).
Parameters
Optional tz: TTimezone
Returns TDate
getTime
Get time.
Returns the time from the start of day in the specified time zone or in the current one, if the time zone is not specified (by default, the company’s time zone).
Parameters
Optional tz: TTimezone
Returns TTime
getTz
Get time zone.
Returns TTimezone
sub
Subtraction of dates. Returns a duration.
Parameters
date: TDatetime
Returns TDuration
truncateTime
Round up to the start of the day.
Resets the time to 00:00 and returns the date in the UTC format.
Returns TDatetime
unix
Number of seconds that have elapsed since
00:00:00 01.01.1970
UTC.Returns number
utc
Returns a date and time in UTC.
Returns TDatetime
Properties
Methods