陣列 時間常用轉化

2021-10-20 18:15:57 字數 918 閱讀 9200

向陣列或物件中插入資料

const arr1 =

['春', '夏', '秋'

]arr1.push(

'冬') // 向陣列插入資料

const obj =[,

]obj[

0].season =

'春天' // 向物件中插入資料

陣列-字串,物件-字串之間的轉換

const a1 = arr1.join(

',') // 將陣列轉化成字串

const a2 = a1.split(

',') // 將字串轉化為陣列

const o1 = json.stringify(obj) // 將物件轉化為字串

const o2 = json.parse(o1) // 將字串轉化為物件

物件陣列 去重

methods: ,,,

] const arr2 = this.unrep(arr)

}, unrep (arr)

}

陣列的深度拷貝:

const arr2 = json.parse(json.stringify(arr))
判斷是否為有效時間

isvaliddate (val)

把時間轉成時間戳

date

.parse

(new

date

(date1))

-date

.parse

(new

date

(date2

))

hive中常用的時間格式轉化

select from unixtime unix timestamp 20180905 yyyymmdd yyyy mm dd select next day current date mo 取當前周的下周一 select date add next day current date mo 7 取...

lua 時間轉化

1 把時間 秒,轉化為xx天xx時xx分xx秒 的形式 把時間 秒,轉化為xx天xx時xx分xx秒 的形式 function converttimeform second local timeday math.floor second 86400 local timehour math.fmod m...

時間型別轉化

jsonformat 於jackson jsonformat pattern yyyy mm dd hh mm ss 結果會有2019 06 15 08 00 00的情況,相差8個小時,因為我們是東八區 北京時間 如下使用timezone,jsonformat pattern yyyy mm dd ...