1

I would like to have a Date like this:

2016-10-14T08:26:33Z

But when i do this:

%%=FormatDate(DateAdd(NOW(), "6", "H"), "yyyy-mm-ddT","hh:mm:ssZ", "nl-NL")=%% 

It returns:

 2016-10-14T 09:04:26-6

Why is there a "-6" and why aren't the date and time together?

1

Z is number of hours your time zone is offset from UTC. Include the Z outside of the function if you want it included, or escape the character within the function with a backslash.

Try: %%=FormatDate(DateAdd(NOW(), "6", "H"), "yyyy-mm-dd\T","hh:mm:ss\Z", "nl-NL")=%%

0

A very slight "improvement" on the current answer, as there are less values to pass and in my test that solution resulted in a lower case z. Each is a work around due to limitations with the timestamp returned by Now().

Using NOW returns Local server time vs GMT so you will always have to adjust to local time. Assuming system time remains -6 (perhaps always or until there are global servers), you can use this to get what you want. It would be great if Now() allowed a parameter to return GMT but currently that isn't available. Additionally, if you are looking for a standard format, culture code is not needed, that parameter is primarily useful to display culture specific output, vs standardize output as is requested here. I have no answer for why a space is added between date and time. A format of "sortable" is also available for both date and time but is imperfect as well for your end goal.
HTH

Concat(Substring(FormatDate(DateAdd(NOW(), "6", "H"), "iso"), 1, 19), "Z")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.