Function: asDate()
asDate(
options
):TTransformer
<Date
,TDate
>
Create a date transformer. Using Tempo to parse and format date string.
Parameters
Parameter | Type | Description |
---|---|---|
options | TempoOptions & DateOptions | TempoOptions for parsing/formatting and DateOptions for validation |
Returns
TTransformer
<Date
, TDate
>
Remarks
Without format option, asDate expects ISO 8601 format
Example
ts
// Default expect ISO 8601 format
Column('createdAt', asDate());
// With custom format and timezone
Column('createdAt', asDate({
format: 'DD/MM/YYYY',
timezone: 'Asia/Bangkok'
}));