View

now(), @updateAt 의 @db.Timestamptz(3)의 유무에 따른 시간  표시

 

@db.Timestamptz(3)가 없는 model

model Voice {
    id	          Int           @default(autoincrement()) @id
    fileSize	    Decimal       @db.Decimal(8,3)           
    url	          String        @db.VarChar(500) 
    user	        User          @relation(fields: [userId], references: [id])       
    userId	      Int           
    sentence      Sentence      @relation(fields: [sentenceId], references: [id])
    sentenceId    Int      
    dateOfCreated DateTime      @default(now())
    dateOfUpdated DateTime      @updatedAt
    voiceStatus   VoiceStatus[]

    @@map("voice")
}

@db.Timestamptz(3)가 있는 model

model Voice {
    id	          Int           @default(autoincrement()) @id
    fileSize	    Decimal       @db.Decimal(8,3)           
    url	          String        @db.VarChar(500) 
    user	        User          @relation(fields: [userId], references: [id])       
    userId	      Int           
    sentence      Sentence      @relation(fields: [sentenceId], references: [id])
    sentenceId    Int      
    dateOfCreated DateTime      @db.Timestamptz(3) @default(now())
    dateOfUpdated DateTime      @db.Timestamptz(3) @updatedAt
    voiceStatus   VoiceStatus[]

    @@map("voice")
}

 

@db.Timestamptz(3)의 목적은 초를 소수점 3째자리까지 표시하기 위해 사용하는 것이 컸으나, 

이를 사용하지 않아도, now()와 @upsatedAt 자체만으로도 소수점 3째자리까지 표시하고있다.

여기서 달라지는게 있다면, 1~4번 의 날짜는 타임존이 우리나라 기준이 아닌 UTC 기준이라는 것이다.

아래 결과처럼 5,6번만 현재 타임존 기준으로 시간이 찍혔다. - Asia/Seoul

 

Share Link
reply
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31