在Google Apps脚本方法中修改日期格式的最佳方法是什么?

发布于 2025-02-08 18:09:20 字数 448 浏览 1 评论 0原文

我已经搜索了网站上的类似问题,但是我没有找到针对我情况的答案。我试图在此构造中显示当前日期:DD-mmm-yy,最后没有UTC时间。过去,在其他功能中,我能够成功使用以下操作:.setnumberformat,但是在我现在正在使用的功能中,它无法正常工作,并且显示了全日期。

这是我使用的代码:

function updateLTD(e) {
  // Code designed to insert current date to the "LTD" sheet.
  var date = new Date();

  if (e.range.columnStart != 1 || !e.value) return;
  e.range.offset(0,3).setValue(date).setNumberFormat("dd-MMM-yy");
}

如何在当前代码中制作此工作?感谢任何建议。

I have searched the site for similar questions but I did not find an answer specific to my situation. I am trying to display the current date in this formate: dd-MMM-yy, without the UTC time at the end. In the past in other functions I was able to have success using this: .setNumberFormat but in the function I am working on now, it won't work and it displays the full date.

This is my code I am using it in:

function updateLTD(e) {
  // Code designed to insert current date to the "LTD" sheet.
  var date = new Date();

  if (e.range.columnStart != 1 || !e.value) return;
  e.range.offset(0,3).setValue(date).setNumberFormat("dd-MMM-yy");
}

How to make this work in my current code? I appreciate any suggestions.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文