250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- Props
- CLASS
- useState
- middleware
- error
- solidity
- nextJS
- API
- typeScript
- node.js
- CSS
- 삶
- built in object
- Ethereum
- graphQL
- blockchain
- hardhat
- concept
- evm
- web
- HTML
- REACT
- Redux
- SSR
- bitcoin
- tailwindcss
- express.js
- JavaScript
- 기준
- Interface
Archives
- Today
- Total
ReasonJun
javascript : built-in object (time, json) 본문
728x90
time
const data = new Date();
console.log(date);
const d1 = new Date(2022, 11, 16, 12, 57, 30);
// Dec 16, 2022 12:15:30
//? .getFullYear(), .setFullYear()
console.log(d2.getFullYear()); // Extract year only
data.setFullYear(2023); // specify the year
//? .getMonth() .setMonth()
// Returns/specifies the month. (zero-based numbering)
//? .getDate() .setDate()
// 'Returns / specifies 'day'.
//? .getHours() .setHours()
// Returns/specifies the hour.
//? .getMinutes() .setMinutes()
// Returns/specifies minutes.
//? .getSeconds() / .setSeconds()
// 'Returns / specifies 'seconds'.
//? .getDay()
// Returns the 'day' of the date instance.
// 0 : Sunday 1 : Monday ~ 6 : Saturday
const data1 = new Date();
const day = date.getDay();
console.log(day);
//? .getTime() .setTime()
// Convert/specify to 'ms' of the date instance.
Date.prototype.isAfter = function (data) {
const a = this.getTime();
const b = date.getTime();
return a > b;
};
const d2 = new Date('');
const d3 = new Date('');
console.log(d1.isAfter(d2)); // false
console.log(d2.isAfter(d1)); // true
// Date.now()
// Elapsed since '1970-01-01 00:00:00' (Unix time),
// 'ms' when the method is called is returned.
const time = new Date().getTime();
console.log(Date.now());
console.log(time);
console.log(now.toString()); // Tue Jan 24 2023 15:31:52 GMT+0900 (Korean Standard Time)
console.log(now.toDateString()); // Tue Jan 24 2023
console.log(now.toTimeString()); // 15:31:52 GMT+0900 (Korean Standard Time)
console.log(now.toISOString()); // ISO 8601 => 2023-01-24T06:31:52.984Z
console.log(now.toLocaleString('en-US')); // 1/24/2023, 3:31:52 PM
console.log(now.toLocaleString('ko-KR')); // 2023. 1. 24. 오후 3:31:52
json
// JSON (Javascript Object Notation)
// Standard format for passing data
// Use only letters, numbers, booleans, nulls, objects, and arrays
// A single json can hold only one type of data.
// Use only double quotes for characters
// No trailing comma
// Use the .json extension
// JSON.stringfy() = Convert the data to JSON characters.
// JSON.parse() = Parses JSON characters and converts them into data.
console.log(JSON.stringify('Hello world!')); // "Hello world!"
console.log(JSON.parse('"Hello world!"')); // Hello world!
728x90
'Frontend > Javasciprt' 카테고리의 다른 글
Javascript : Function (2) | 2023.06.07 |
---|---|
Javascript : class (0) | 2023.06.07 |
javascript : built-in object (object, string) (0) | 2023.06.07 |
javascript : built-in object (number, math, url) (0) | 2023.06.07 |
javascript : variable (4) (array, shallow copy) (4) | 2023.06.07 |
Comments