日历/公历的JavaScript等价代码

huangapple go评论63阅读模式
英文:

Calendar / GregorianCalendar equivalent Javascript

问题

function generateDateTime() {
  const calendar = new Date();
  const date = null;
  calendar.setTime(date.getTime());
  return Math.floor((calendar.getTime() / 1000 - 0) / 30);
}

// How can I translate this function to node js / javascript?

// Is this calendar.getTimeinMillis equivalent of Date.getTime() ?
英文:
  public static final long generateDateTime() {
    Calendar calendar = GregorianCalendar.getInstance();
    Intrinsics.checkExpressionValueIsNotNull(calendar, "GregorianCalendar.getInstance()");
    Date date = (Date)null;
    calendar.setTimeInMillis(date.getTime());
    return (calendar.getTimeInMillis() / 1000L - 0L) / 30L;
  }

How can I translate this function to node js / javascript?

Is this calendar.getTimeinMillis equivalent of Date.getTime() ?

答案1

得分: 1

可以使用moment.js来实现这一点。

尝试使用moment(...).valueOf()

英文:

Yes, you can do this with moment.js.

Try with moment(...).valueOf()

huangapple
  • 本文由 发表于 2020年9月17日 22:16:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/63940049.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定