如何知道订阅开始日期和月结束日期在条纹json数据?



我正在尝试使用nodejs检索订阅对象数据到我的项目。下面是订阅对象。无论用户何时注册,我都要存储他们的订阅日期和下一次订阅日期。我认为它是

"current_period_end": 1613973928,
"current_period_start": 1611295528

但是当我转换时间1613973928在Localstring中给出:

"Mon Jan 19 1970 21:49:33 GMT+0530 (India Standard Time)"

应该是今天的日期。

{
"id": "sub_Inubyr5OJUppaI",
"object": "subscription",
"application_fee_percent": null,
"billing_cycle_anchor": 1611295528,
"billing_thresholds": null,
"cancel_at": null,
"cancel_at_period_end": false,
"canceled_at": null,
"collection_method": "charge_automatically",
"created": 1611295528,
"current_period_end": 1613973928,
"current_period_start": 1611295528,
"customer": "cus_InubUu9jTKtevF",
"days_until_due": null,
"default_payment_method": null,
"default_source": null,
"default_tax_rates": [],
"discount": null,
"ended_at": null,
"items": {
"object": "list",
"data": [
{
"id": "si_InubRpC6JA0U6W",
"object": "subscription_item",
"billing_thresholds": null,
"created": 1611295528,
"metadata": {},
"price": {
"id": "price_1Hvs1yGQ1LZjNPNJTN3wuIX0",
"object": "price",
"active": true,
"billing_scheme": "per_unit",
"created": 1607379486,
"currency": "usd",
"livemode": false,
"lookup_key": null,
"metadata": {},
"nickname": null,
"product": "prod_IWvtx3h0tCJQ7c",
"recurring": {
"aggregate_usage": null,
"interval": "month",
"interval_count": 1,
"usage_type": "licensed"
},
"tiers_mode": null,
"transform_quantity": null,
"type": "recurring",
"unit_amount": 29900,
"unit_amount_decimal": "29900"
},
"quantity": 1,
"subscription": "sub_Inubyr5OJUppaI",
"tax_rates": []
}
],
"has_more": false,
"url": "/v1/subscription_items?subscription=sub_Inubyr5OJUppaI"
},
"latest_invoice": "in_1ICIlwGQ1LZjNPNJZGi0UDF0",
"livemode": false,
"metadata": {},
"next_pending_invoice_item_invoice": null,
"pause_collection": null,
"pending_invoice_item_interval": null,
"pending_setup_intent": null,
"pending_update": null,
"schedule": null,
"start_date": 1611295528,
"status": "active",
"transfer_data": null,
"trial_end": null,
"trial_start": null
}

Unix时间戳以秒为单位,但JS以毫秒为单位:

new Date(1613973928 * 1000).toLocaleDateString()
// '2/22/2021'

最新更新