简体   繁体   English

如何以 date-fns 格式转义模式字母

[英]How to escape pattern letters in date-fns format

I need time in the format xx min, yy seconds我需要xx min, yy seconds格式的时间

For which I am doing format(new Date(99999), 'mm min, ss seconds') using date-fns s format .为此,我正在使用date-fns s format进行format(new Date(99999), 'mm min, ss seconds')

However it prints 31 31in, 39 39econ439 .但是它会打印31 31in, 39 39econ439

What I want is 1 min, 39 seconds我想要的是1 min, 39 seconds

So I need 2 things所以我需要两件事

  1. how to escape the m in mins and s,d in seconds如何在mins逃脱m并在seconds逃脱s,d
  2. how to make it count absolute time from epoch rather than adding +5.30 of the timezone如何让它从纪元开始计算绝对时间,而不是添加 +5.30 时区

1.) You can escape by using quotes: 1.) 您可以使用引号转义:

"mm 'min', ss 'seconds"

2.) You need to get the date in unix: 2.) 您需要在 unix 中获取日期:

Math.round((new Date()). getTime() / 1000);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM