How Do I Get the Current Time?

Aug 16, 2008 at 1:32am

How Do I Get the Current Time?

I’m trying to timestamp some data I’m feeding into a collection, so I started by looking at the the example patch for the [date] object. I want to mark some data with the current time from the computer’s clock. The date object doesn’t seem to be doing this for me.

The description of the object indicates that “date reports the current date, time, and the number of 1/60th-of-a-second ticks since startup.”

It’s not clear that the date object is doing that, either. Presently, my computer’s clock indicates that the time is 9:29:15pm. When I send the time message into the [date] object, I get back 1 29 15 in the list. I didn’t turn my computer on exactly at the top of the hour, so I find it strange that the minutes and seconds are correct, but the hour is completely wrong.

Does the date object take the computer’s timezone into account or must my program handle that?

system: Windows Vista Home Premium SP1 on an AMD-based notebook.

thanks,

Michael

#39300
Aug 16, 2008 at 1:44am

You could try the java ‘now’ object. It’s in both 4.6 and 5.0.

Brad

On 15-Aug-08, at 7:32 PM, Michael Chladil wrote:

>
> I’m trying to timestamp some data I’m feeding into a collection, so
> I started by looking at the the example patch for the [date]
> object. I want to mark some data with the current time from the
> computer’s clock. The date object doesn’t seem to be doing this for
> me.
>
> The description of the object indicates that “date reports the
> current date, time, and the number of 1/60th-of-a-second ticks since
> startup.”
>
> It’s not clear that the date object is doing that, either.
> Presently, my computer’s clock indicates that the time is
> 9:29:15pm. When I send the time message into the [date] object, I
> get back 1 29 15 in the list. I didn’t turn my computer on exactly
> at the top of the hour, so I find it strange that the minutes and
> seconds are correct, but the hour is completely wrong.
>
> Does the date object take the computer’s timezone into account or
> must my program handle that?
>
> system: Windows Vista Home Premium SP1 on an AMD-based notebook.
>
> thanks,
>
> Michael

#138174
Aug 16, 2008 at 1:46am

Are you sure you aren’t getting 21 29 15? The date object reports the time in 24-hour format.

#138175
Aug 16, 2008 at 2:36am

thanks for the suggestions…

Holland, I was definitely getting a “1″ rather than “21″. I was using the example patch for the date object. I tried resizing the number box, but no luck. I’m at GMT-5, so I wrote a little code to try to adjust things that way, but I was off by one somehow. I’m interested to see what happens when I turn off my computer and turn it on again.

Brad, I couldn’t find the “now” object in java/js, but I found an earlier post in these forums that led me to the Date object in js, which has member functions such as getHours, getMinutes, getSeconds. This seems to suit my purpose.

#138176
Aug 16, 2008 at 2:37am

On Aug 15, 2008, at 6:32 PM, Michael Chladil wrote:

> Does the date object take the computer’s timezone into account or
> must my program handle that?

As far as I know, yes.

This is more or less the helpfile, but it works for me here (Max 5.0.4/
OSX 10.5.4 intel):

– Pasted Max Patch, click to expand. –

Chris Muir
cbm@well.com

http://www.xfade.com

#138177
Aug 16, 2008 at 3:14am

For both 4.6 and 5.0 look in Cycling ’74 > java > help > now.help. It
gives you day of week, month, day, year, hour, minute, second,
millisecond, am / pm, day of year, week of year, and week of month.
This is on a Mac, though.
Brad

On 15-Aug-08, at 7:32 PM, Michael Chladil wrote:

>
> I’m trying to timestamp some data I’m feeding into a collection, so
> I started by looking at the the example patch for the [date]
> object. I want to mark some data with the current time from the
> computer’s clock. The date object doesn’t seem to be doing this for
> me.
>
> The description of the object indicates that “date reports the
> current date, time, and the number of 1/60th-of-a-second ticks since
> startup.”
>
> It’s not clear that the date object is doing that, either.
> Presently, my computer’s clock indicates that the time is
> 9:29:15pm. When I send the time message into the [date] object, I
> get back 1 29 15 in the list. I didn’t turn my computer on exactly
> at the top of the hour, so I find it strange that the minutes and
> seconds are correct, but the hour is completely wrong.
>
> Does the date object take the computer’s timezone into account or
> must my program handle that?
>
> system: Windows Vista Home Premium SP1 on an AMD-based notebook.
>
> thanks,
>
> Michael

#138178
Aug 16, 2008 at 6:09am

Guess you already treid it, bt for me, this works perfectly on my computer:

Cheers

– Pasted Max Patch, click to expand. –
#138179
Aug 16, 2008 at 11:52am

If you’re really getting an hour report that’s off by 20 hours, it’s quite possibly a bug on the Windows side. I wrote code converting Windows date/time info to a format matching existing Mac-oriented date/time code that I had, and it was gnarly. Easy enough for something to go awry.

In fact, if you’re at GMT-5 *and* you’re on Daylight Savings/Summer time, that might explain the situation. -5 + 1 == 20 mod 24.

I’d suggest you put together a stripped down patch and submit it (with a screen shot of the time display) as a bug report.

– P

#138180

You must be logged in to reply to this topic.