モバイルデバイスの普及に伴い、Web ページでの JavaScript の適用はますます一般的になってきています。携帯電話では、携帯電話の時刻を取得して設定する必要があることがよくあります。今日は、JavaScriptを使用して携帯電話の時刻を設定する方法を共有します。
- 現在時刻の取得
JS では、Date()
オブジェクトを使用して現在時刻を取得できます。コードは次のとおりです。
var now = new Date(); var year = now.getFullYear(); //获取当前年份 var month = now.getMonth() + 1; //获取当前月份 var day = now.getDate(); //获取当前日期 var hour = now.getHours(); //获取当前小时数 var min = now.getMinutes(); //获取当前分钟数 var sec = now.getSeconds(); //获取当前秒数
- 現在の時刻を設定します
Date()
オブジェクトの setFull Year()# を使用できます。 ##,
setMonth(),
setDate(),
setHours(),
setMinutes(),
setSeconds() 時間を設定するメソッド。コードは次のとおりです。
var now = new Date(); now.setFullYear(2021); //设置年份为2021年 now.setMonth(6); //设置月份为7月 now.setDate(15); //设置日期为15日 now.setHours(12); //设置小时为12点 now.setMinutes(30); //设置分钟为30分 now.setSeconds(0); //设置秒数为0秒
- 時刻の書式設定
Date() オブジェクトの
toLocaleDateString()、
toLocaleTimeString()、
toLocaleString()、
toDateString() を使用できます。 ,
toTimeString(),
toString() メソッドで時間をフォーマットします。コードは次のとおりです。
var now = new Date(); console.log(now.toLocaleDateString()); //输出格式为“2021/7/15” console.log(now.toLocaleTimeString()); //输出格式为“下午12:30:00” console.log(now.toLocaleString()); //输出格式为“2021/7/15 下午12:30:00” console.log(now.toDateString()); //输出格式为“Thu Jul 15 2021” console.log(now.toTimeString()); //输出格式为“12:30:00 GMT+0800 (中国标准时间)” console.log(now.toString()); //输出格式为“Thu Jul 15 2021 12:30:00 GMT+0800 (中国标准时间)”
- 携帯電話の時刻を設定します
cordova-plugin-datetimepicker## を使用する必要があります。 # 時刻を設定するプラグイン。このプラグインは、ユーザーが時間を設定できるポップアップ ボックスを提供します。コードは次のとおりです。 <pre class='brush:php;toolbar:false;'>cordova.plugins.DateTimePicker.show({
mode: 'datetime',
titleText: '设置时间',
date: now,
allowOldDates: true,
allowFutureDates: true,
minuteInterval: 5
},
function (date) {
console.log(date); //输出所选的时间
},
function (error) {
console.log(error); //输出错误信息
});</pre>
上記は、携帯電話の JavaScript を使用して時刻を設定する方法です。お役に立てれば幸いです。
以上が携帯電話のJavaScriptの設定時間の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

raceslimitationsinclude:1)asteeplearningcurveduetoitsvastecosystem、2)seochallengeswithsclient-siderEndering、3)潜在的なパフォーマンスのinlargeapplications、4)complenstatemanagementasappsgrow、and5)suneedtokeepupwithovolution

ReactisChallengingを使用して、SteepLearNdParadigMshiftOconpontenAchitecture.1)startisofficialdocumentation forasolidfoundation.2)relondingjsxandjavascriptwithinit.3)LearntousefunctionalcompotontiTateを理解してください

coreChallengeingEneratingは、duniqueys consinistinsidentifientiversre-renderseforeffiencedomupdates.1)aseenaturalKeysisisisisisisisedisederiableiableiaibuniqueandStable.2)denatekeysBaseTheBasedOnMultipreattributive.2)を無効にすることを非難することを解決します

javascriptfatigueinReactismainageable with rikeislikedivedingingindininginginformationscors.1)whatyouneedwhenyouneedit、focusingonprojectrelevance.2)

ESTESTROACTCOMPONENTSINGTHESESTATEHOOK、USEJESTANDREACTINTINGLIBRARYTOSIMULATE INTERACTIONSIONDANDVERIFYISTAMESISINTHEUI.1)RENDERTHECONCENTANDCHECKECHINITATA.2)SimulateUserIractionSionsionsionsionsionsionslikeClickSorformSubmissions.3)

keysinReactarecialforptimizingperformancebyididingineffictientListupdates.1)usekeystoidentifideidifyandtracklistelements.2)ArrayIndicesassyStopreventPerformanceSues.3)suoseStableidedifierslikeItem.idtomaincomentaindtateandiproveperift

ReactKeySareUniqueIdentifiersiersiderSuredStrovereconconiniationEfficiency.1)theyctrackChangesinListitems、2)sultanduniqueidentifiersiirsiTeemidssisssississmendを使用して、3)ArrayIndicesAssayStopReventisSuseSUSEORINGを回避します

sinqueysarecrucialinReactforoptimizing andMaintainingcomponentStateIntegrity.1)useanaturaluniqueidentifierfromyourdataifaibable.2)ifnonaturalidentifierexists、発電済みのKeyusingingingingalibrarylikuuid.3)


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

SublimeText3 中国語版
中国語版、とても使いやすい

VSCode Windows 64 ビットのダウンロード
Microsoft によって発売された無料で強力な IDE エディター

ドリームウィーバー CS6
ビジュアル Web 開発ツール

Dreamweaver Mac版
ビジュアル Web 開発ツール

SublimeText3 Linux 新バージョン
SublimeText3 Linux 最新バージョン

ホットトピック









