Issue
i have my data in cloud fire store. its have different collection in it . in a collection the name of the document is the time(he format is hour:00) as you can see in the picture( attached ). I want to get the data of this document by round off the time is the same format
for example the local time is 15:40 pm i want to round of the time as 15:00
so please let me know how to proceed for such problem and if you have any reference please let me know
right now what I'm getting is in the format( hour : minutes) but I want the q(please check the code) is the format as hour:00 so how I can round off the time as ( hour :00)
the code right now i have is
p = time.localtime() q= time.strftime("%H:%M", p)
result = db.collection('TOU').document(q).get()
thank you
Solution
If I interpret this correctly the question is actually about how to get the last full hour based on the current time.
You are nearly there, just replace the formatting specifier %M
with 00
q = time.strftime("%H:%M", p) # --> 13:59
to
q = time.strftime("%H:00", p) # --> 13:00
For future reference, please take some time to boil the question down to the actual core of what you are after, the info about the cloud fire store adds no value. Had you done so I'm pretty sure you would have discovered the solution on your own. And please format the code, it makes it way easier to read for the rest of us making us more likely to help you :)
If my answer works for you I would be happy if you mark it as the accepted solution.
Answered By - Martin Riddar
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.