1

Hello I want to round my Date() variable to 3 digits after seconds, example below:

The initial value: 2012-08-29T21:28:28.8789063+03:00
The value I want to achieve: 2012-08-29T21:28:28.88

Or if I can't really do this, I want to remove 10 chars starting from end, if so how could I do that?

Cœur
  • 37,241
  • 25
  • 195
  • 267
skmasq
  • 4,470
  • 6
  • 42
  • 77

2 Answers2

0

use the substring or substr function and take 10 characters off from the length

Jay
  • 88
  • 3
0

I use the jQuery dateFormat plugin to format dates.

To just strip off the last 10 chars, try:

date = dateObj.toString();
formattedDate = date.substr(0, date.length-10);
gpojd
  • 22,558
  • 8
  • 42
  • 71