Hnub parse ua dab tsi hauv JavaScript?
Hnub parse ua dab tsi hauv JavaScript?

Video: Hnub parse ua dab tsi hauv JavaScript?

Video: Hnub parse ua dab tsi hauv JavaScript?
Video: Data Science with Python! Analyzing File Types from Avro to Stata 2024, Kaum ib hlis
Anonim

Kev piav qhia. Cov parse () txoj kev yuav siv ib hnub hlua (xws li "2011-10-10T14: 48: 00") thiab xa rov qab cov lej milliseconds txij lub Ib Hlis 1, 1970, 00: 00: 00 UTC. Qhov no muaj nuj nqi yog pab tau rau kev teeb tsa hnub tus nqi raws li txoj hlua qhov tseem ceeb, piv txwv li nrog rau cov txheej txheem setTime() thiab cov Hnub tim khoom.

Cov lus nug tseem yog, JavaScript parse ua dab tsi?

parse () txoj kev parses ib txoj hlua JSON, tsim lub JavaScript tus nqi lossis khoom piav qhia los ntawm txoj hlua. Ib qho kev xaiv reviver muaj nuj nqi ua tau muab los ua ib qho kev hloov pauv ntawm cov khoom tshwm sim ua ntej nws yog rov qab los.

Tsis tas li ntawd, hnub tim JavaScript siv sijhawm li cas? UTC

Kuj Paub, hnub JavaScript ua haujlwm li cas?

A JavaScript hnub tim yog qhov tseem ceeb tau teev tseg raws li tus naj npawb ntawm milliseconds uas tau dhau los txij thaum ib tag hmo thaum Lub Ib Hlis 1, 1970, UTC. Qhov no hnub thiab lub sijhawm yog tib yam li UNIX lub sijhawm, uas yog tus nqi tseem ceeb tshaj plaws rau lub computer-sau. hnub thiab lub sijhawm muaj nuj nqis.

Kuv tuaj yeem sib piv ob hnub hauv JavaScript li cas?

Hauv JavaScript , peb ua tau piv ob hnub los ntawm kev hloov lawv mus rau hauv tus lej lej kom sib haum rau nws lub sijhawm. Ua ntej, peb tuaj yeem hloov cov Hnub tim rau hauv tus lej tus nqi los ntawm kev siv getTime() muaj nuj nqi. Los ntawm converting qhov muab hnub tim rau hauv tus lej tus nqi peb tuaj yeem ncaj qha piv lawv.

Pom zoo: