how i can transform date format in "dd-MM-yyyy" i'm getting this in this format "yyyy-MM-dd" here is code in my entity
@IsOptional()
@ApiProperty({ example: '1999-12-12', nullable: true })
@Column({ type: 'date', nullable: true })
birthDate?: Date;
im trying to transform in this format "dd-MM-yyyy"
The toLocaleDateString
with the wanted locale in argument will help you.
transformDate(date: string): string {
const options = { year: 'numeric', month: '2-digit', day: '2-digit' };
return new Date(date).toLocaleDateString('en-US', options);
}