Post time stamp works but wrong time

Post time stamp works but wrong time

Anonymous
Not applicable
992 Views
9 Replies
Message 1 of 10

Post time stamp works but wrong time

Anonymous
Not applicable

Added this to my post to add a time stamp when I posted it.  Works fine but it posts out 4 hours ahead.  It's wrong in the dump file too.

 

      if (hasGlobalParameter("generated-at"))                      
  {                                                    
      var generated = getGlobalParameter("generated-at");
      if (generated)
     {
      writeComment("POSTED: " + generated);
      }
  }

Is there anything I can change here or is Inventor pulling the wrong time?

0 Likes
Accepted solutions (1)
993 Views
9 Replies
Replies (9)
Message 2 of 10

Laurens-3DTechDraw
Mentor
Mentor

Pretty sure it just takes the PC's time.

Laurens Wijnschenk
3DTechDraw

AutoDesk CAM user & Post editor.
René for Legend.


0 Likes
Message 3 of 10

Anonymous
Not applicable

I added this snippet to my post as well and see the same result:

 

Computer time was 10:15 AM, note in program was 2:15 PM

I wonder if it outputs the value in UTC?

 

Steve

 

 

0 Likes
Message 4 of 10

Anonymous
Not applicable

PC time is correct.  

This code gives me the right time but in a different format.  I liked the format of the generated-at but if its the wrong time then it's not worth it.

var now = new Date();
    writeComment("POSTED: " + (now.getMonth()+1) + "/" + now.getDate() + "/" + now.getFullYear() + " " + now.getHours() + ":" + now.getMinutes());

@Laurens-3DTechDraw Does your dumper have the right time?

0 Likes
Message 5 of 10

ivan.stanojevic
Advisor
Advisor
My dumper shows 3:03pm and now is 5:03 pm...


Ivan Stanojevic


0 Likes
Message 6 of 10

Anonymous
Not applicable

What time zone are you in Ivan?

 

0 Likes
Message 7 of 10

ivan.stanojevic
Advisor
Advisor

@Anonymous wrote:

What time zone are you in Ivan?

 


I'm in UTC +01:00 (CET)



Ivan Stanojevic


0 Likes
Message 8 of 10

Anonymous
Not applicable

I'm Currently Eastern Daylight Time (EDT), UTC -4 because of daylight saving time.  So I'm normally in Eastern Standard Time (EST), UTC -5

dump posts: 3:44:00 PM

actual time: 11:44:00 AM

 

So it looks like it pulling UTC and not looking at your time zone.

Is there a way have the bump factor in timezone?

 

 

0 Likes
Message 9 of 10

parobillard
Advocate
Advocate
Accepted solution

Hi

 

Here's a bypass

 

Somewhere in the post:

function myDate() {
	var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
	var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
	var d = new Date();
	return days[d.getDay()] + ", " + months[d.getMonth()] + " " + d.getDate() + ", " +  d.getFullYear() + " " + (d.getHours() > 12 ? d.getHours() - 12 : d.getHours()) + ":" + d.getMinutes() + ":" + d.getSeconds() + " " + (d.getHours() < 12 ? "AM" : "PM");
}

then use 

writeComment(myDate());
0 Likes
Message 10 of 10

Anonymous
Not applicable

Thanks @parobillard  

That works pretty good.  It doesn't fix Inventor not taking into account the time zone but it puts it into the right format, which is what I was after.

0 Likes