I helped do this in the AHL last year. Could be a lot different from what they do in the NHL, but you never know.
All you had was a laptop with a custom Ice-time logging program. Each player was listed by their number and organized in lines. You'd click the line name if the whole line came out, or each individual player if needed. Click them once and it counts up, click them again and it stops.
It absolutely wasn't perfect down to the second, but it was pretty close. One-person job....quite simple, but we only did the home team. It kind of sucked when you had special jerseys with hard-to-read numbers.
There are stat people who keep track of when players are on the ice. NHL.com has shift charts for every game so you can see who was on the ice when. They aren't going to be 100% accurate but over the course of the season things will mostly even out.