Loading...

Format JavaScript Date to yyyy-mm-dd

Temperature: 0 °C

Mark ChangMark Chang
author_tools


Format JavaScript Date to yyyy-mm-dd
JavaScript將Sun May 01,2018轉換成yyyy-mm-dd

function formatDate(date) {
var d = new Date(date),
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
year = d.getFullYear();

if (month.length < 2) month = '0' + month;
if (day.length < 2) day = '0' + day;

return [year, month, day].join('-');
}
document.getElementById('res').innerHTML = formatDate('Sun May 01,2018') ;

以上紀錄~

https://innstory.com/story-Format_JavaScript_Date_to_yyyymmdd-1530
javascript

Next
解決iphone_不能使用colorbox_滑動的方式 

About the Author

Mark Chang

離不開電腦的宅男

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

使用JavaScript的split函式完成字串切割

使用JavaScript的s...

使用JavaScript的split 函式可以用來切割字串。 根據設定的切割點執行切開的動作。 以下...

PHP查詢陣列中是否存在特定字串in_array() 函數

PHP查詢陣列中是否存在特定...

使用函數inarray() ,適用版本(PHP , PHP 5, PHP , PHP ) 使用方式:...

修改php設定

修改php設定

pexelsphoto55 進入系統 用文字編輯軟體打開php.ini改變以下設定 disablef...

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format