How Do I Get the Current Time?

Michael Chladil's icon

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

bdc's icon

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

Holland Hopson's icon

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

Michael Chladil's icon

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.

Chris Muir's icon

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):

Max Patch
Copy patch and select New From Clipboard in Max.

Chris Muir
cbm@well.com    
http://www.xfade.com

bdc's icon

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

jazzisfaction's icon

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

Cheers

Max Patch
Copy patch and select New From Clipboard in Max.

Peter Castine's icon

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

Nicen's icon

I have a similar problem, but the minutes are off, as shown below

badtimes

Christopher Dobrian's icon

Fwiw, if you're going to be comparing time tags, or measuring the time between them, but don't care about the actual time of day, cpuclock is good.