I have two cisco switches (WS-C3850-12XS-E) stacked by stack cable. I want to configure ntp on them. How to configure ntp on those about time synchronization?
You configure a stack as a single switch, not two separate switches. Simply log into the stack and configure NTP:
ntp server ip-address [version number] [key key-id] [source interface-type interface-number] [prefer]
There are other options and configurations for NTP, but the above command will configure the switch stack to use a particular NTP server.
You can refer to Basic System Management Configuration Guide, Cisco IOS XE Release 2, Setting Time and Calendar Services for more information.