Create a gist now

Instantly share code, notes, and snippets.

Embed
what is this i don't even
> ''+(new Date(1000))
'Wed Dec 31 1969 18:00:01 GMT-0600 (CST)'
> ''+(new Date())
'Sat Aug 13 2011 00:13:14 GMT-0500 (CDT)'
@chrisdickinson

This comment has been minimized.

Show comment
Hide comment
@chrisdickinson

chrisdickinson Aug 13, 2011

give Date a number, it's standard time. don't give date a number? daylight savings time.

Owner

chrisdickinson commented Aug 13, 2011

give Date a number, it's standard time. don't give date a number? daylight savings time.

@SlaunchaMan

This comment has been minimized.

Show comment
Hide comment
@SlaunchaMan

SlaunchaMan Aug 13, 2011

I’m going to guess it’s because Wednesday, Dec 31 1969 (which is Jan. 1 1970 + 1000 milliseconds, adjusted for your time zone) was not during Daylight Savings Time, whereas Sat Aug 13 is. Since Daylight Savings Time does not apply to UTC, the timezone offset changes for dates that are in DST for your locale.

I’m going to guess it’s because Wednesday, Dec 31 1969 (which is Jan. 1 1970 + 1000 milliseconds, adjusted for your time zone) was not during Daylight Savings Time, whereas Sat Aug 13 is. Since Daylight Savings Time does not apply to UTC, the timezone offset changes for dates that are in DST for your locale.

@chrisdickinson

This comment has been minimized.

Show comment
Hide comment
@chrisdickinson

chrisdickinson Aug 13, 2011

@SlaunchaMan Ooh, good catch. I think the real issue that I'm having with this is that there's no explicit way to set the UTC offset of a new Date object.

Owner

chrisdickinson commented Aug 13, 2011

@SlaunchaMan Ooh, good catch. I think the real issue that I'm having with this is that there's no explicit way to set the UTC offset of a new Date object.

@SlaunchaMan

This comment has been minimized.

Show comment
Hide comment
@SlaunchaMan

SlaunchaMan Aug 13, 2011

I can see how that would be a problem. :)

I can see how that would be a problem. :)

@tbranyen

This comment has been minimized.

Show comment
Hide comment
@tbranyen

tbranyen Aug 13, 2011

tim in ~ $ node
> ''+(new Date(1000))
'Wed Dec 31 1969 19:00:01 GMT-0500 (EST)'
> ''+(new Date())
'Sat Aug 13 2011 01:19:37 GMT-0400 (EDT)'
> +new Date()
1313212826216
> ''+(new Date(1313212826216))
'Sat Aug 13 2011 01:20:26 GMT-0400 (EDT)'
tim in ~ $ node
> ''+(new Date(1000))
'Wed Dec 31 1969 19:00:01 GMT-0500 (EST)'
> ''+(new Date())
'Sat Aug 13 2011 01:19:37 GMT-0400 (EDT)'
> +new Date()
1313212826216
> ''+(new Date(1313212826216))
'Sat Aug 13 2011 01:20:26 GMT-0400 (EDT)'
@chrisdickinson

This comment has been minimized.

Show comment
Hide comment
@chrisdickinson

chrisdickinson Aug 13, 2011

@tbranyen so, given '1313212826216 -0600', how do you convert that into UTC?

Owner

chrisdickinson commented Aug 13, 2011

@tbranyen so, given '1313212826216 -0600', how do you convert that into UTC?

@chrisdickinson

This comment has been minimized.

Show comment
Hide comment
@chrisdickinson

chrisdickinson Aug 13, 2011

this might be what I'm going for -- show the originating "local" time for a timestamp, along with the UTC offset.

(e.g., given 1310976115000 -0700 and I am UTC-0500 (CDT), I want to see 'Mon Jul 18 01:01:55 2011 -0700', not 'Mon Jul 18 2011 03:01:55 GMT-0500 (CDT)'

Owner

chrisdickinson commented Aug 13, 2011

this might be what I'm going for -- show the originating "local" time for a timestamp, along with the UTC offset.

(e.g., given 1310976115000 -0700 and I am UTC-0500 (CDT), I want to see 'Mon Jul 18 01:01:55 2011 -0700', not 'Mon Jul 18 2011 03:01:55 GMT-0500 (CDT)'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment