time changed to integer and simpler javascript