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
  • 34,719
  • 24
  • 185
  • 251
skmasq
  • 4,344
  • 6
  • 40
  • 75

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
  • 21,634
  • 8
  • 41
  • 71