HarmonyOS Next中如何在arkts中格式化时间戳?-灵析社区

接地气的编码师

口味你好,你可以通过以下示例代码转换: let date = new Date(1710161336 * 1000); const year = date.getFullYear(); const month = ("0" + (date.getMonth() + 1)).slice(-2); const day = ("0" + date.getDate()).slice(-2); const hours = ("0" + date.getHours()).slice(-2); const minutes = ("0" + date.getMinutes()).slice(-2); const seconds = ("0" + date.getSeconds()).slice(-2); let formattedDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`

阅读量:1

点赞量:0

问AI