Javasriptでyesterday取得
var now = new Date();
const yesterday = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1);
kinkun's blog
Javasriptでyesterday取得
var now = new Date();
const yesterday = new Date(now.getFullYear(), now.getMonth(), now.getDate() - 1);
Javasriptでtoday取得
const today = new Date();
const yyyy = today.getFullYear();
let mm = today.getMonth() + 1;
let dd = today.getDate();
const yyyymmdd = yyyy + "," + mm + "," + dd;
console.log('yyyymmdd:'+yyyymmdd);
var startDate = new Date(yyyymmdd);
console.log('startDate:'+startDate);
Javasriptでtomorrow取得
const today = new Date();
const tomorrow = new Date(today);
tomorrow.setDate(tomorrow.getDate() + 1);
const yyyyTomorrow = tomorrow.getFullYear();
let mmTomorrow = tomorrow.getMonth() + 1;
let ddTomorrow = tomorrow.getDate();
const yyyymmddTomorrow = yyyyTomorrow + "," + mmTomorrow + "," + ddTomorrow;
console.log('yyyymmddTomorrow:'+yyyymmddTomorrow);
var endDate = new Date(yyyymmddTomorrow);
console.log('endDate:'+endDate);
クエリでendAt使用例
const today = new Date();
const yyyy = today.getFullYear();
let mm = today.getMonth() + 1;
let dd = today.getDate();
const yyyymmdd = yyyy + "," + mm + "," + dd;
var startDate = new Date(yyyymmdd);
const tomorrow = new Date(today);
tomorrow.setDate(tomorrow.getDate() + 1);
const yyyyTomorrow = tomorrow.getFullYear();
let mmTomorrow = tomorrow.getMonth() + 1;
let ddTomorrow = tomorrow.getDate();
const yyyymmddTomorrow = yyyyTomorrow + "," + mmTomorrow + "," + ddTomorrow;
console.log('yyyymmddTomorrow:'+yyyymmddTomorrow);
var endDate = new Date(yyyymmddTomorrow);
console.log('endDate:'+endDate);
firebase.firestore()
.collectionGroup("samplecollection")
.orderBy("createdAt", "asc").startAt(startDate).endAt(endDate)
.limit(10)
.get()
.then(querySnapshot => {
querySnapshot.forEach(doc => {
console.log('success');
}, (error) => {
console.log('error');
});
})
Javasriptでtomorrow取得
https://flaviocopes.com/how-to-get-tomorrow-date-javascript/
mapでkeyを変数値にする方法
const key = "age"
const value = "10"
const result = {[key]:value}
console.log(result)
クエリでstartAt使用例
const today = new Date();
const yyyy = today.getFullYear();
let mm = today.getMonth() + 1;
let dd = today.getDate();
const yyyymmdd = yyyy + "," + mm + "," + dd;
var startDate = new Date(yyyymmdd);
firebase.firestore()
.collectionGroup("samplecollection")
.orderBy("createdAt", "asc").startAt(startDate)
.limit(10)
.get()
.then(querySnapshot => {
querySnapshot.forEach(doc => {
console.log('success');
}, (error) => {
console.log('error');
});
})
カラーコード変換ツール
多次元配列でサイズ取得
let userData = [
['a', 2, 'Tokyo'],
['b', 3, 'Fukuoka'],
['c', 4, 'Sendai']
];
let user1 = userData[0];
console.log(userData.length);
console.log(user1[0].length);
結果
3
3