Reputation: 14618
I'm trying to format a date in a Slack message via the Web API. I'm using Botkit and thus my fields are being parsed with Mustache, however logs show that the correct formatting is coming out afterwards (therefore I don't think Mustache is the issue here).
The message as shown in Botkit debug logs is "... on <!date^1511407982054^{date_long_pretty} at {time}|Wednesday at 10am> ..."
. Other <formatting>
in the message works just fine both before and after this occurrence.
I'm sure I'm at fault, but can't figure out how. Any help would be appreciated.
Slack rendering:
Some things I've tried:
new Date().getTime()
to generate the value. Tried using new Date().getTime() * 1000
in case there was a difference there (moment.js does a * 1000 when you ask for a unix epoch number - maybe units are different).Upvotes: 1
Views: 2898
Reputation: 14618
Turns out I needed to use Math.floor(new Date().getTime() / 1000)
to generate the Unix timestamp
Upvotes: 3