2

How can I set date and time in a hikvision camera from linux command line? Or from some language, like Python, PHP, etc... I have a computer connected to cameras, and I want to change date and time in cameras without access to browser, only from terminal. Thanks

Rui Martins
  • 3,337
  • 5
  • 35
  • 40

2 Answers2

3

You might use the document HIKVISION ISAPI . as you know, interface depends on camera firmware version. For setting date and time for camera. you needs HTTP PUT method with URL

http://hikvision_camera_ipaddress[:http_port]/ISAPI/System/time.

On general, An IP camera has 3 types of time mode; NTP, manual, sync(timecorrect for HIKVISION).

It would be better for getting date and time of the camera through GET method first with the same above url. After that you will get a hint for HTTP body for setting date and time via PUT method.

For more detail you could refer the document 8.1.9

agfe2
  • 492
  • 7
  • 15
1

If your camera supports onvif you can use python library called python-onvif (for 2.x):

pip install onvif

or python-zeep-onvif(for 3+):

pip3 install --upgrade onvif_zeep

Python code:

from onvif import ONVIFCamera
camera_ip = "your camera ip"
camera_port = "your camera port, default is 80"
wsdl_path = "path to wsdl folder"
cam = ONVIFCamera(args.ip, 80, login, password, wsdl_path)
time_request = cam.devicemgmt.create_type('SetSystemDateAndTime')
time_request.DateTimeType = "Manual"
time_request.DaylightSavings = True
time_request.UTCDateTime.Time.Hour = 4 
time_request.UTCDateTime.Time.Minutes = 20
time_request.UTCDateTime.Time.Seconds = 0
cam.devicemgmt.SetSystemDateAndTime(time_request)

Please, check python-onvif package page and onvif operation page for more detailed info

Mike Mint
  • 145
  • 5