8 Replies - 748 Views - Last Post: 14 October 2013 - 02:22 PM Rate Topic: -----

#1 Inuinu172  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 55
  • Joined: 17-July 13

Getting time from other countries [task]

Posted 03 October 2013 - 04:34 AM

What im trying to do:
print the current time in a different country when a command is run.

What ive tried:
I have spent a few hours messing with the pytz module, and searching on stackoverflow, with no luck.

What I have tried:
I have tried getting my current time, Setting it as a variable, then using

mytime = time.strftime('%I')
ctime = int(mytime) + int(6)
print(str(ctime)+time.strftime(':%M:%S %p')



But the time needs to be in 12 hour time, Not 24 and needs to display the am/pm.

Thanks in advance :)

Is This A Good Question/Topic? 0
  • +

Replies To: Getting time from other countries [task]

#2 BlueMelon  Icon User is offline

  • D.I.C Head

Reputation: 40
  • View blog
  • Posts: 187
  • Joined: 27-April 10

Re: Getting time from other countries [task]

Posted 05 October 2013 - 09:52 AM

Wouldn't the pytz module be ideal for what you're trying to do? Try and give it another shot, there are some great examples in the documentation.
Was This Post Helpful? 0
  • +
  • -

#3 DblAAssassin  Icon User is offline

  • D.I.C Regular

Reputation: 34
  • View blog
  • Posts: 261
  • Joined: 11-May 13

Re: Getting time from other countries [task]

Posted 05 October 2013 - 11:16 AM

Is there any specific timezone you wish to display, or do you want the current time, depending on the user's timezone?
Was This Post Helpful? 0
  • +
  • -

#4 Inuinu172  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 55
  • Joined: 17-July 13

Re: Getting time from other countries [task]

Posted 05 October 2013 - 11:38 AM

View PostDblAAssassin, on 05 October 2013 - 11:16 AM, said:

Is there any specific timezone you wish to display, or do you want the current time, depending on the user's timezone?


Now one specific timezone, and not the users.
depending on what the user inputs is what the time will display.
example being

>>> time NZ
>>> 7:37 am
>>>
>>> time UK
>>> reply with time


Was This Post Helpful? 0
  • +
  • -

#5 DblAAssassin  Icon User is offline

  • D.I.C Regular

Reputation: 34
  • View blog
  • Posts: 261
  • Joined: 11-May 13

Re: Getting time from other countries [task]

Posted 05 October 2013 - 12:17 PM

What exactly do you need help, with?
Was This Post Helpful? 0
  • +
  • -

#6 Inuinu172  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 55
  • Joined: 17-July 13

Re: Getting time from other countries [task]

Posted 06 October 2013 - 09:19 AM

View PostDblAAssassin, on 05 October 2013 - 12:17 PM, said:

What exactly do you need help, with?


Read the topic, It explains rather clearly what I need help with.
Was This Post Helpful? -2
  • +
  • -

#7 DblAAssassin  Icon User is offline

  • D.I.C Regular

Reputation: 34
  • View blog
  • Posts: 261
  • Joined: 11-May 13

Re: Getting time from other countries [task]

Posted 14 October 2013 - 09:40 AM

View PostInuinu172, on 06 October 2013 - 09:19 AM, said:

View PostDblAAssassin, on 05 October 2013 - 12:17 PM, said:

What exactly do you need help, with?


Read the topic, It explains rather clearly what I need help with.


No, in the original post, you say you want to display a time depending on the time zone the user is in. Now your saying you just want one timezone. That, could also be considered as merging topics, which is not allowed. So, you you please state which one you need help with.

Option 1
Display time depending on which time zone the user is in?

Option 2
Display a time, in a specific time zone?

Option 1 or 2?
Was This Post Helpful? 0
  • +
  • -

#8 Inuinu172  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 55
  • Joined: 17-July 13

Re: Getting time from other countries [task]

Posted 14 October 2013 - 09:43 AM

View PostDblAAssassin, on 14 October 2013 - 09:40 AM, said:

View PostInuinu172, on 06 October 2013 - 09:19 AM, said:

View PostDblAAssassin, on 05 October 2013 - 12:17 PM, said:

What exactly do you need help, with?


Read the topic, It explains rather clearly what I need help with.


No, in the original post, you say you want to display a time depending on the time zone the user is in. Now your saying you just want one timezone. That, could also be considered as merging topics, which is not allowed. So, you you please state which one you need help with.

Option 1
Display time depending on which time zone the user is in?

Option 2
Display a time, in a specific time zone?

Option 1 or 2?


Option 2. Sorry for the confusion.
Was This Post Helpful? 0
  • +
  • -

#9 DblAAssassin  Icon User is offline

  • D.I.C Regular

Reputation: 34
  • View blog
  • Posts: 261
  • Joined: 11-May 13

Re: Getting time from other countries [task]

Posted 14 October 2013 - 02:22 PM

I, don't know if you have or not but I would look at BlueMelon's post (second post), and just take it piece by piece. Basically use pytz module.

  • Get, you time to display.
  • Get it to display in 12 hour format.
  • Have it display AM or PM
  • Make it where you can enter a time zone, and it will display.


Hope this helped, if you have any problems with the code, you can make a new topic, and we will be glad to help!
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1