I want to retrieve slack messages pasted between 4 pm to 4:30 pm daily from a certain slack channel. Slack provides a Web API for a channel as https://api.slack.com/methods/channels.history
The above API provides 2 attributes as latest
& oldest
, this means i can extract the messages between these 2 timestamps. But my problem is that these are time stamp and i have to make a request for timestamp as:
latest 1459750060.000002 #end
oldest 1459750060.000002 #start
I want to pass the 2 data as simple time objects i.e
latest_simple = 0430pm #end
oldest_simple = 0400pm #start
latest_real_format = convert_to_timestamp(latest_simple)
oldest_real_format = convert_to_timestamp(oldest_simple )
so if somehow i am able to get the timestamp , then i will easily be able to send make request to API as
payload = {'token': 'XXXXXXXx', 'channel': 'C0L8MGLMN' , 'latest': latest_real_format , 'oldest':oldest_real_format }
r = requests.get('https://slack.com/api/channels.history', params=payload)
How can i do this ?
Two 'H' in HH is for 24-hour format. Description as to why this works would be useful. Such as HH for 24 hour format as hh for 12 hour.
In SQL Server 2012, we can use Format function to have suitable date time format. Use capital letter 'HH:mm:ss' for 24 hour date time format.
You can return to 12-hour time by tapping Use 24-Hour Format again. Tap Select Date Format. Tap one of the three format options to change the date format. If you don't want to change the date format, tap Cancel.
The timestamps are UNIX epoch in milliseconds. Assuming you are using Python here are examples how to convert it to datetime and back. As already mentioned in the comments you need to include the date in your "simple timestamp" for which you want to retrieve the messages for.
From date/time to timestamp: Convert string date to timestamp in Python
From timestamp to date/timp: Convert microsecond timestamp to datetime in Python
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With