Forums > Javascript

Date object in Javascript

April 23, 2008 | 2:40 pm

Hi, I ham having problems with the ‘date’ object in max due to the spaces that it places between each character, i need to be able to query date, and have that query returned as e.g 23/04/2008, I have tried string concantation etc, but with no sucess, was wondering how this could be acheived in javascript, I attempted using the *_date.getSeconds(); etc, but due to limited experience, do not know how to do this properly, any help would be much appreciated, many thanks Ed


April 23, 2008 | 4:07 pm

On Apr 23, 2008, at 7:40 AM, Ed Hamilton wrote:
>
> Hi, I ham having problems with the ‘date’ object in max due to the
> spaces that it places between each character, i need to be able to
> query date, and have that query returned as e.g 23/04/2008, I have
> tried string concantation etc, but with no sucess, was wondering how
> this could be acheived in javascript, I attempted using the
> *_date.getSeconds(); etc, but due to limited experience, do not know
> how to do this properly, any help would be much appreciated, many
> thanks Ed

I’d suggest the simple max way–i.e. date->sprintf %.2d/%2.d/%d
(example below). However for the Date reference, please see the
javascript developer resources on mozilla.org. However, there is a bug
with the JS Date object in Max 4.6 on MacTel which gives garbage
results. This is fixed in Max 5.

-Joshua

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 47 185 116 196617 sprintf %.2d/%2.d/%d;
#B color 5;
#P message 47 243 103 196617 04/23/2008;
#P newex 47 212 62 196617 prepend set;
#B color 5;
#P newex 47 156 36 196617 date;
#B color 5;
#P message 47 126 37 196617 date;
#P connect 4 0 2 0;
#P connect 1 0 4 0;
#P connect 2 0 3 0;
#P connect 0 0 1 0;
#P window clipboard copycount 5;


April 23, 2008 | 5:05 pm

No need of js for this, [sprintf %ld /%ld /%ld] should work.

Ciao


April 23, 2008 | 5:49 pm

On 23-avr.-08, at 18:07, Joshua Kit Clayton wrote:

> However, there is a bug with the JS Date object in Max 4.6 on MacTel
> which gives garbage results. This is fixed in Max 5.

I just discovered that and wanted to find some pattern to reproduce the
bug and send a bug report… I was using the js date to create a
filename and it was always wrong!

I’m glad it’s fixed.

^p


Viewing 4 posts - 1 through 4 (of 4 total)