I have just managed to solve this problem. so I share it here, maybe
someone else can also make use of it.
1. clone the javasript $:/core/modules/macros/now.js to
$:/USERNAME/modules/macros/utc.js
2. change the line
exports.name = "now";
to
exports.name = "utc";
this will be the name of the new macro
and change the macro part to:
/*
Run the macro
*/
exports.run = function(format) {
var now = new Date();
return $tw.utils.formatDateString(new Date(now.getUTCFullYear(),
now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(),
now.getUTCSeconds()),format || "YYYY0MM0DD0hh0mm0ss");
};
now I can use <<utc>> and get an utc timestamp.
I don't know javascript at all, I just searched on the web and happened to
find a workable solution. probably there are better ways to do this.
for other beginner like me: you need to refresh the TW5 before the
javascript macro can be used.
I wish all have a nice day!
chaonuo
On Saturday, August 22, 2015 at 8:47:13 PM UTC+8, chaonuo wrote:
>
> hi everybody,
>
> For my purpose I need to set a "date" field for my agenda Tiddlers and
> enter a timestamp as its value. Since the "created" and "modified" are in
> UTC time, I think it is more properly if my "date" field also uses UTC
> time. At present I use the macro <<now>> to generate a current local
> timestamp (in my case UTC+8) and then edit it by hand.
>
> How does one get an UTC timestamp instead? Is there an equivalent macro
> for generating UTC timestamps?
>
> thanks !
>
>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/c712d1fa-43b9-4160-982c-9a0c6a376205%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.