DateTime ua haujlwm li cas hauv C#?
DateTime ua haujlwm li cas hauv C#?

Video: DateTime ua haujlwm li cas hauv C#?

Video: DateTime ua haujlwm li cas hauv C#?
Video: Plab Plab Ntswg..(Pluav Pluav Ntswg) Maiv Twm New Song 2023-2024 2024, Kaum ib hlis
Anonim
  • Cov Hnub tim hom nqi sawv cev rau hnub tim thiab lub sijhawm nrog cov nqi txij li 00:00:00 (ib tag hmo), Lub Ib Hlis 1, 0001 Anno Domini (Common Era) txog 11:59:59 P. M., Kaum Ob Hlis 31, 9999 AD (C. E.) hauv Gregorian daim ntawv qhia hnub.
  • Lub sij hawm muaj nuj nqis yog ntsuas hauv 100-nanosecond units hu ua zuam.

Raws li, DateTime ua haujlwm li cas hauv C#?

Ua haujlwm Nrog Hnub tim Siv C# Cov C# Hnub tim qauv sawv cev rau hnub tim thiab lub sij hawm nyob rau hauv C# thiab. Hauv C# , cov Hnub tim qauv sawv cev rau hnub thiab sijhawm. Tus nqi ntawm DateTime yog nruab nrab ntawm 12:00:00 ib tag hmo, Lub Ib Hlis 1, 0001 txog 11:59:59 P. M., Kaum Ob Hlis 31, 9999 AD

Ib tug kuj yuav nug, Dab tsi yog DateTime hom hauv C#? Hnub tim yog tus nqi Hom zoo li int, ob npaug thiab lwm yam yog li tsis muaj txoj hauv kev los muab tus nqi null. Thaum a hom tuaj yeem muab null nws yog hu ua nullable, uas txhais tau tias tus hom tsis muaj nqi. Txhua Daim Ntawv Qhia Hom yog nullable los ntawm default, e.g. String, thiab tag nrho ValueTypes tsis yog, xws li. Ib 32.

Ib tug kuj nug, DateTime UtcNow yog dab tsi hauv C#?

Hnub tim . UtcNow rov a Hnub tim tus nqi sawv cev rau lub sijhawm tam sim no Universal Co-ordinated Time (aka UTC) uas yuav zoo ib yam tsis hais lub sijhawm ntawm lub sijhawm. Cov Hnub tim . Kind khoom yuav yog DateTimeKind. Utc.

Kuv puas yuav tsum siv DateTime lossis DateTimeOffset?

Cov no siv rau DateTimeOffset cov nqi muaj ntau ntau dua li cov rau Hnub tim tus nqi. Vim li ntawd, DateTimeOffset yuav tsum raug suav hais tias yog hom hnub thiab sijhawm rau kev txhim kho daim ntawv thov. kuv pom Hnub tim raws li tau txais txiaj ntsig thaum koj xav nrog cov hnub nkaus xwb, lub sijhawm nkaus xwb, lossis cuam tshuam nrog ib qho kev nkag siab zoo.

Pom zoo: