You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How can I save a ISO 8601 UTC date in Datastore with a date and time index #599
Hi @jgeewax, I don't think that will work as Date gives me a back a Date object in my local timezone (GMT+0100), which is then stored in the Datastore in UTC format.
I want to pass in a UTC date string to begin with using something like moment.utc().toJSON()
var localTZ = moment('2013-05-14T13:01:00.234Z').toDate();
console.log(localTZ); // Tue May 14 2013 14:01:00 GMT+0100 (IST) <- Date Object Local TZ
console.log(localTZ.toJSON()); // 2013-05-14T13:01:00.234Z <- UTC
var utc = moment.utc('2013-05-14T13:01:00.234Z'); <- UTC
console.log(utc.toJSON()); // 2013-05-14T13:01:00.234Z <- UTC
Hm, I think this is a question of broader scope than gcloud-node...
Any objection to taking this over to Stack Overflow? I think it's probably going to get answered better there.. You effectively need to get a timezone-aware Javascript Date object... I believe that once you have that, gcloud-node will handle it properly, right @ryanseys ?
Nope doesn't look like a bug in our code, we just get the number of milliseconds since the last Epoch using:
vard=newDate(Date.parse('2013-05-14T13:01:00.234Z'));// set start to this object.d.getTime()// num of milliseconds since epoch - no notion of timezone here
then multiply by 1000 to get microseconds and set that value to timestamp_microseconds_value.
Here's showing that the date is properly parsed as UTC (same as GMT):
>newDate(Date.parse('2013-05-14T13:01:00.234Z'))TueMay14201309:01:00GMT-0400(EDT)>newDate(Date.parse('2013-05-14T13:01:00.234Z')).toUTCString()'Tue, 14 May 2013 13:01:00 GMT'
Activity
jgeewax commentedon May 14, 2015
I think what you want is...
or if you use Moment.js:
/cc @ryanseys As I think he had some docs that explained this, but I don't see them live on the gh-pages hosted site.
byrneciaran commentedon May 14, 2015
Hi @jgeewax, I don't think that will work as
Dategives me a back a Date object in my local timezone (GMT+0100), which is then stored in the Datastore in UTC format.I want to pass in a UTC date string to begin with using something like
moment.utc().toJSON()jgeewax commentedon May 14, 2015
Hm, I think this is a question of broader scope than gcloud-node...
Any objection to taking this over to Stack Overflow? I think it's probably going to get answered better there.. You effectively need to get a timezone-aware Javascript
Dateobject... I believe that once you have that, gcloud-node will handle it properly, right @ryanseys ?ryanseys commentedon May 14, 2015
Yep.
ryanseys commentedon May 14, 2015
This might be a bug. I'll look into it now.
ryanseys commentedon May 14, 2015
Nope doesn't look like a bug in our code, we just get the number of milliseconds since the last Epoch using:
then multiply by
1000to get microseconds and set that value totimestamp_microseconds_value.Here's showing that the date is properly parsed as UTC (same as GMT):
ryanseys commentedon May 14, 2015
To answer your original question, try this:
ryanseys commentedon May 24, 2015
@byrneciaran any update on whether this helped you?
stephenplusplus commentedon Jun 4, 2015
I think we this one is covered, but @byrneciaran, feel free to re-open if it didn't work. Thanks for getting us to double check how we handle dates!
23 remaining items
chore: release 5.1.0 (#599)
feat: propagate spanIds (#599)
chore: release 4.1.0 (#608)
feat(params): adds optional param types (#599)
feat: propagate spanIds (#599)
chore: release 4.1.0 (#608)
migrate code from googleapis/cloud-profiler-nodejs (#7087)
chore(main): release 3.2.1 (#599)
chore: release 5.1.0 (#599)
chore: release 5.1.0 (#599)
chore: remove console.log in system test (#599)
fix(deps): update dependency google-auth-library to v4 (#599)
chore(deps): update dependency @types/mocha to v8 (#599)
chore(main): release 6.3.0 (#599)
chore: remove console.log in system test (googleapis#599)