Well, one simple method which comes into my head is: when a player makes some decision which launches some action that requires some time to finish, it is best to mark its time of completion on the server side. Then, I think, your JS could just store that time and show to the player a timer.
Although, it is simple what I wrote here, I have to emphasize one thing: time of completion MUST be stored on your server. I have seen some games like the one you described (my dad once played one of such a game), and I saw that many players search for some “hack” to speed up their building process in a game. If, for example, you would chose to place all that time counting system in JS then a savvy player may simply ignore your JS program and write his own and then use it to force your server-side program to finish building something before time.