show clock

show clock
import requests
import json
 
"""
Modify these please
"""
url='http://<ip_address>:<port_number>/ins'
switchuser='<user_id>'
switchpassword='<password>'
 
myheaders={'content-type':'application/json'}
payload={
"ins_api":{
  "version": "1.0",
  "type": "cli_show",
  "chunk": "0",
  "sid": "1",
  "input": "show clock",
  "output_format": "json"
  }
} 
response = requests.post(url,data=json.dumps(payload), headers=myheaders,auth=(switchuser,switchpassword)).json()
output = json.dumps(response, indent=4, sort_keys=True)

json_output = json.loads(output)["ins_api"]["outputs"]["output"]["body"]
print(json.dumps(json_output, indent=4, sort_keys=True))
{
    "simple_time": "21:15:47.432 UTC Wed Jun 26 2019",
    "time_source": "NTP"
}
       <time_source>NTP</time_source>
       <simple_time>21:15:47.532 UTC Wed Jun 26 2019</simple_time>
      

The show clock command displays the current system date and time. For command descriptions, see the Cisco MDS 9000 Series Switches Command References.

Note: This sample output is generated for Cisco MDS 9000 Series NX-OS Release 8.4(2a) or later.

CLI Output
switch# show clock

Warning: No NTP peer/server configured. Time may be out of sync.
Time source is NTP
21:15:47.373 UTC Wed Jun 26 2019
ParameterDescriptionType
time_source Time source informationString
simple_timeTime clock format (in 'HH':'mm':'ss' 'UTC' day MM dd yyyy)String