Lub sij hawm ntawv puas muaj lub sij hawm?
Lub sij hawm ntawv puas muaj lub sij hawm?

Video: Lub sij hawm ntawv puas muaj lub sij hawm?

Video: Lub sij hawm ntawv puas muaj lub sij hawm?
Video: Sheng Her ft. Blia Lor - Lub Sij Hawm (Official Music Video) 2024, Hlis ntuj nqeg
Anonim

Lub ntsiab txhais ntawm UNIX daim ntawv teev sijhawm yog lub sijhawm ywj siab. Cov daim ntawv teev sijhawm yog tus naj npawb ntawm vib nas this (lossis milliseconds) dhau los txij li qhov taw qhia meej hauv lub sijhawm, ib tag hmo ntawm Lub Ib Hlis 1 1970 hauv UTC lub sijhawm. Txawm koj lub sijhawm , a daim ntawv teev sijhawm sawv cev rau lub sijhawm uas zoo ib yam nyob txhua qhov chaw.

Ua raws li qhov no saib, lub sijhawm teev sijhawm nrog TimeZone yog dab tsi?

Cov daim ntawv teev sijhawm hom ntaub ntawv tso cai rau koj khaws ob hnub thiab sijhawm. Txawm li cas los xij, nws tsis muaj thaj tsam cov ntaub ntawv. Nws txhais tau tias thaum koj hloov koj lub database server's thaj tsam , cov daim ntawv teev sijhawm tus nqi khaws cia hauv database tsis hloov. Cov ntaub ntawv timestamptz yog cov timestamp nrog lub sijhawm.

Puas yog timestamps ib txwm UTC? Unix daim ntawv teev sijhawm yog ib txwm nyob ntawm UTC (lwm lub npe hu ua GMT). Nws yog tsim nyog hais tias "ib Unix daim ntawv teev sijhawm hauv vib nas this", lossis "ib Unix daim ntawv teev sijhawm Ib txhia nyiam cov lus "milliseconds txij thaum Unix epoch (tsis hais txog leap vib nas this)".

Tsuas yog li ntawd, kuv yuav tau txais timestamp li cas los ntawm lub sijhawm?

Koj tsis tuaj yeem tau a TimeZone ID los ntawm ib qho TimeStamp ”, uas yog tsis yooj yim sua. Koj suav-ntawm-lub sijhawm tau ua thaum suav nyiaj rau qee yam thaj tsam , feem ntau UTC. Yog tias yuav tsum paub tias thaj chaw npaj siv los tsim qhov suav-ntawm-lub sijhawm, nws tsis tuaj yeem txiav tawm.

Muaj pes tsawg tus lej yog lub sijhawm?

Ib tug siv tau daim ntawv teev sijhawm suav nrog mus txog 6 tus lej ntawm precision. Yog ntxiv tus lej muaj nyob rau hauv input qhov tseem ceeb, lub daim ntawv teev sijhawm yog puag ncig. Cov piv txwv hauv qab no qhia tus cwj pwm thaum sib txawv cov txiaj ntsig tau muab tso rau hauv a TIMESTAMP kem. Qhov ntau ntawm cov hnub siv tau hauv daim ntawv teev sijhawm yog los ntawm 01-01-0001 txog 12-31-9999.

Pom zoo: