Dab tsi yog tus nqi qub ntawm timestamp hauv MySQL?
Dab tsi yog tus nqi qub ntawm timestamp hauv MySQL?

Video: Dab tsi yog tus nqi qub ntawm timestamp hauv MySQL?

Video: Dab tsi yog tus nqi qub ntawm timestamp hauv MySQL?
Video: Koj Hais Dab Tsi?/Suabci Kwm & Ab Meej Ham/Official MV 2023 2024, Tej zaum
Anonim

Nyob rau hauv pawg lus, kab Create_at yog a TIMESTAMP kem uas tus nqi pib yog teeb rau CURRENT_TIMESTAMP. Raws li koj tuaj yeem pom los ntawm cov zis, MySQL siv lub daim ntawv teev sijhawm thaum lub sij hawm ntxig raws li a default tus nqi rau tsim_at kem.

Hais txog qhov no, tus nqi pib rau hnub tim hauv MySQL yog dab tsi?

MySQL's default DATE daim teb hom yog YYYY-MM-DD. Qhov kev txhawb nqa yog 1000-01-01 txog 9999-12-31. DATETIME hom yog hnub thiab sijhawm ua ke, thiab khaws cov ntaub ntawv hauv YYYY-MM-DD HH: MM: SS hom.

Tsis tas li ntawd, kuv yuav ua li cas thiaj tsim tau lub sijhawm nyob hauv MySQL? $ daim ntawv teev sijhawm = date("Y-m-d H:i:s"); Qhov no yuav muab koj hnub tim thiab lub sij hawm tam sim no nyob rau hauv ib txoj hlua hom uas koj ua tau ntxig rau hauv MySQL . Koj tuaj yeem sim wiht TIMESTAMP (curdate(), curtime()) siv sij hawm tam sim no. ces xwb ntxig txhua kab rau hauv lub rooj yam tsis muaj qhov tseem ceeb rau lub sijhawm.

Qhov thib ob, lub sijhawm tam sim no yog dab tsi hauv MySQL?

MySQL CURRENT_TIMESTAMP() Muaj nuj nqi Lub CURRENT_TIMESTAMP() muaj nuj nqi rov qab tam sim no hnub thiab sijhawm. Nco tseg: Hnub thiab sijhawm xa rov qab yog "YYYY-MM-DD HH-MM-SS" (txoj hlua) lossis raws li YYYYMMDDHHMMSS. uuuuuu (numeric).

Daim ntawv teev sijhawm yog dab tsi?

Cov TIMESTAMP hom ntaub ntawv yog siv rau qhov tseem ceeb uas muaj ob hnub thiab sijhawm. TIMESTAMP muaj ntau yam ntawm '1970-01-01 00:00:01' UTC rau '2038-01-19 03:14:07' UTC. LUB DATETIME los yog TIMESTAMP tus nqi tuaj yeem suav nrog qhov txuas ntawm cov lej thib ob hauv mus txog microseconds (6 tus lej) qhov tseeb.

Pom zoo: