How to add a Unix Timestamp in an email? | Community
Skip to main content
September 22, 2016
Solved

How to add a Unix Timestamp in an email?

  • September 22, 2016
  • 1 reply
  • 3921 views

Hi there,

I need to add a Unix format timestamp of NOW() into links that appear in an email.

example: blablabla.com?timestamp=1474549200

I'm guessing I need to use a Velocity script to do this but I can't get it right. Can someone put me on the right track?

Thanks,

Thomas

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

${date.getSystemTime()}

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
September 22, 2016

${date.getSystemTime()}

September 23, 2016

Thanks a lot Sanford!

May I ask where I can find online documentation on this function and other date/time related functions?

On another note, is there another function that returns the timestamp without the milliseconds? Or do I need to truncate the last 3 digits to get that?

Thomas

SanfordWhiteman
New Participant
September 23, 2016

On another note, is there another function that returns the timestamp without the milliseconds? Or do I need to truncate the last 3 digits to get that?

${math.floor($math.div($date.getSystemTime(),1000))}

May I ask where I can find online documentation on this function and other date/time related functions?

Start with the DateTool docs: DateTool (VelocityTools 2.0-beta4 Documentation)

But the problem with learning all this stuff -- or at least the ​rightest/tightest way to do what you want -- is that if you don't understand the underlying Java objects (maybe you do) then the way Velocity subsets/abstracts it may not make sense to you.  A Java developer would find Velocity the 2nd-best thing to Java itself, since via VTL you end up having access to thousands of functions that are familiar (if not particularly easy to use, as an honest Java developer will tell you).  A non-developer, or even a PHP or Ruby developer, might be thinking, ​"What the heck, I just wanted a templating language with some output formatting."

I'm adding more and more Velocity-related content to my blog (see the tag blog.teknkl.com/tag/velocity).  I pitch it at the Marketo technical power user, which is, I hope, a lot more accessible than most pages out there, which are pitched at professional developers.  But it's hard not to talk about Java principles and such.