node.js - 如何在 Angular 6 中获取 EPOCH 日期时间格式?

标签 node.js angular angular6

我希望我的日期、时间采用 Angular 的 EPOCH 格式。谁能帮我如何获取 EPOCH 格式的日期?

let UCCdateformated = formatDate(today, 'yyyy-MM-dd', 'en-US', '+0530');
console.log("UCCdateformated  ",UCCdateformated);

最佳答案

您可以在 Vanilla JavaScript 中执行此操作,而无需依赖任何 Angular 的管道。

要获取当前时刻的纪元时间,

const epochNow = (new Date).getTime();
console.log(epochNow);

要获取特定小时的纪元时间(例如今天中午 12 点的日期),

const epochToday = (new Date).setHours(0,0,0,0).getTime();
console.log(epochToday);

关于node.js - 如何在 Angular 6 中获取 EPOCH 日期时间格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55460586/

相关文章:

javascript - 导入第三方js文件到angular typescript项目

angular - 为什么我应该在 Typescript/Angular 中使用接口(interface)(模型)?

shell - node.js - 向子进程发送快捷键

javascript - 绑定(bind)到 Angular 2 服务中的数据对象的正确方法?

node.js - Node-http-proxy 动态路由表?

angular - 类型 'string' 不可分配给类型 'Moment' 错误

dictionary - 角度 6 : No 'Access-Control-Allow-Origin' header is present on the requested resource

javascript - 在 app init 上检查本地存储的 Angular 6 问题

javascript - 使用 body-parser 和 express 解析嵌套的 JSON

mysql - 将数据存储在 MySQL block 中