What function in Python and PHP can convert time in specified time zone to Unix timestamp?
-
I have a lot of times in various time zones to process, but the mktime() function in both PHP and Python have no parameters about time zone, it just convert to timestamps in my system time zone. Is there any function accept a argument such as +32400 or -32400 for UTC+9?
-
Answer:
In both of those libraries, there is a way to set the time zone used for mktime(). In PHP, it is date_default_timezone_set(). (http://us3.php.net/manual/en/function.date-default-timezone-set.php) In Python, it is setting the "TZ" environmental variable and then calling time.tzset(). (http://docs.python.org/library/time.html#time.tzset) There are other Python solutions, such as using the datetime library, or using the email.utils.mktime_tz() funciton. It might be easier, however, to simply add/subtract the proper number of seconds to adjust after you have already converted in UTC.
Xuan Luo at Quora Visit the source
Related Q & A:
- how to call a function in Python in another function?Best solution by Yahoo! Answers
- How to call functions inside a function in Python?Best solution by Stack Overflow
- What time zone is Alberta in?Best solution by Yahoo! Answers
- How can I change time zone for yahoo mail?Best solution by Yahoo! Answers
- How do you know what time zone you are in?Best solution by wiki.answers.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.