Forums > MaxMSP

date format problem

October 6, 2006 | 9:41 pm

Hi,

I need to output a file with the date format mm:dd:yyyy and time format hh:mm:ss. I use the date object to output the date and time.

However, if the date is 1-9, and the minutes or secs 1-9, I can’t get the 0 before the number to show. I can’t use prepend because it puts a space between the 0 and the single integer, and attemps to query a coll (for example "1, 01; 2, 02; etc.) don’t work either–Max keeps removing the 0 before the single integer.

Any ideas?

Thanks.


October 7, 2006 | 8:04 am

> I need to output a file with the date format mm:dd:yyyy and time
> format hh:mm:ss. I use the date object to output the date and time.
>
> However, if the date is 1-9, and the minutes or secs 1-9, I can’t
> get the 0 before the number to show.

[sprintf] is what you’re looking for.
this has come up a couple of times before, so you might find more
info in the archive.
try this:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 121 55 48 196617 loadbang;
#P toggle 121 79 15 0;
#P newex 121 97 64 196617 metro 1000;
#P newex 136 161 67 196617 unpack 0 0 0;
#P number 237 203 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 121 118 30 196617 time;
#P newex 121 139 40 196617 date;
#P message 113 269 50 196617 02:00:04;
#P number 175 203 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 113 203 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 113 226 147 196617 sprintf set %02d:%02d:%02d;
#P connect 10 0 9 0;
#P connect 2 0 0 1;
#P connect 1 0 0 0;
#P connect 0 0 3 0;
#P connect 6 0 0 2;
#P connect 9 0 8 0;
#P connect 8 0 5 0;
#P connect 7 2 6 0;
#P connect 7 1 2 0;
#P connect 7 0 1 0;
#P connect 4 1 7 0;
#P connect 5 0 4 0;
#P window clipboard copycount 11;


October 11, 2006 | 4:17 pm

Thanks! That’s great!


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