SOLVED

Re: How to add a Unix Timestamp in an email?

Go to solution
Anonymous
Not applicable

How to add a Unix Timestamp in an email?

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

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: How to add a Unix Timestamp in an email?

${date.getSystemTime()}

View solution in original post

5 REPLIES 5
SanfordWhiteman
Level 10 - Community Moderator

Re: How to add a Unix Timestamp in an email?

${date.getSystemTime()}

View solution in original post

Anonymous
Not applicable

Re: How to add a Unix Timestamp in an email?

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
Level 10 - Community Moderator

Re: How to add a Unix Timestamp in an email?

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 http://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.

Anonymous
Not applicable

Re: How to add a Unix Timestamp in an email?

Thanks for that, Sanford.

I checked out your blog, lots of great ideas! Must work on my "Web Page Views"...

Cheers,

Thomas

SanfordWhiteman
Level 10 - Community Moderator

Re: How to add a Unix Timestamp in an email?

Cool, and take particular note of how I used $math.div to divide.  Try the more intuitive $field/1000 and you'll see one of Velocity's big surprises.