I have two string like "2007-03-27T08:54:43+08:00 "
how do I get the hours between these two time(string format)? 6 1334
lookonI have two string like "2007-03-27T08:54:43+08:00 " how do I get
lookonthe hours between these two time(string format)?
Look in PyPI for dateutil, then:
>>import dateutil.parser t1 = dateutil.parser.parse("2007-03-27T08:54:43+08:00") t1
datetime.datetime(2007, 3, 27, 8, 54, 43, tzinfo=tzoffset(None, 28800))
>>t2 = dateutil.parser.parse("2007-03-29T10:00:00+02:00") >>t2
datetime.datetime(2007, 3, 29, 10, 0, tzinfo=tzoffset(None, 7200))
>>t2 - t1
datetime.timedelta(2, 25517)
Skip
Thank you for your help.It works.
However, I am using Google App Engine and cannot import dateutil and
epsilon.
Are there any other ways?
On Oct 8, 10:06*pm, s...@pobox.com wrote:
* * lookonI have two string like "2007-03-27T08:54:43+08:00 " how do I get
* * lookonthe hours between these two time(string format)?
Look in PyPI for dateutil, then:
* * >>import dateutil.parser
* * >>t1 = dateutil.parser.parse("2007-03-27T08:54:43+08:00")
* * >>t1
* * datetime.datetime(2007, 3, 27, 8, 54, 43, tzinfo=tzoffset(None,28800))
* * >>t2 = dateutil.parser.parse("2007-03-29T10:00:00+02:00") >>>t2
* * datetime.datetime(2007, 3, 29, 10, 0, tzinfo=tzoffset(None, 7200))
* * >>t2 - t1
* * datetime.timedelta(2, 25517)
Skip
lookonThank you for your help.It works. However, I am using Google
lookonApp Engine and cannot import dateutil and epsilon.
I don't know how Google App Engine works, but are you not able to install
pure Python modules?
lookonAre there any other ways?
Take a look at the time.strptime function to generate a tuple, then use
t = time.strptime(timestamp, format)
t1 = datetime.datetime(*t[0:6])
Note that with this solution you will have to handle the timezone offset
yourself.
Skip
but can you tell me what format is it?
in the str there is a float and I can not deal with it
On Oct 9, 7:20*pm, s...@pobox.com wrote:
* * lookonThank you for your help.It works. *However, I am using Google
* * lookonApp Engine and cannot import dateutil and epsilon.
I don't know how Google App Engine works, but are you not able to install
pure Python modules?
* * lookonAre there any other ways?
Take a look at the time.strptime function to generate a tuple, then use
* * t = time.strptime(timestamp, format)
* * t1 = datetime.datetime(*t[0:6])
Note that with this solution you will have to handle the timezone offset
yourself.
Skip
I have solved the problem. thank you
On Oct 9, 7:20*pm, s...@pobox.com wrote:
* * lookonThank you for your help.It works. *However, I am using Google
* * lookonApp Engine and cannot import dateutil and epsilon.
I don't know how Google App Engine works, but are you not able to install
pure Python modules?
* * lookonAre there any other ways?
Take a look at the time.strptime function to generate a tuple, then use
* * t = time.strptime(timestamp, format)
* * t1 = datetime.datetime(*t[0:6])
Note that with this solution you will have to handle the timezone offset
yourself.
Skip
lookonbut can you tell me what format is it?
Read the strftime man page on your computer or Google for strftime or read
the Python docs about the time.strftime function. (strftime and strptime
strive to have the same set of format characters.)
Skip This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: sg_s123 |
last post by:
============================================================================
02-Feb-04 03-Feb-04
Staff Staff 0800hr- 1300hr- 1700hr- 1900hr- 0800hr- 1300hr- 1700hr-
1900hr-
Number...
|
by: Tim Quon |
last post by:
Hi
Is there any function to get the current time so I can calculate the
execution time of my code?
What all is in the time.h and sys/times.h?
Thanks
Tim
|
by: Herrcho |
last post by:
in K&R Chapter 6.3
it mentions two methods to calculate NKEYS.
and points out the first one which is to terminate the list of
initializers with a null pointer, then loop along keytab until the...
|
by: Qwert |
last post by:
Hello,
I do:
Debug.WriteLine("A: " & DateTime.Now.Ticks.ToString)
REM Calculate a bunch of stuff. Some loops and math functions.
Debug.WriteLine("B: " & DateTime.Now.Ticks.ToString)
but...
|
by: Bujji |
last post by:
Hi,
How to calculate Heap memory used by a process in HPUX machine
(Itanium) using aCC compiler at run time ( My ultimate aim is to
calculate heap memory at run-time and write it into a log...
|
by: Michael |
last post by:
Hi. I need dinamically calculate input text field based on parent static TD
before showing content of input. Please, advice.
Michael
|
by: Beemer Biker |
last post by:
I cant seem to get that date into any DateTime to make my calculation
directly by subtracting "01-01-0000" from "now".
After reading this:...
|
by: Lancelot |
last post by:
Hello everyone. This is my first post here, but I've been looking for answer many time.
I have a crazy idea in my head and since I am quite a newby to python, I am not sure where to start or if...
|
by: brendanmcdonagh |
last post by:
Hi,
I am designing a project for my friend as I am just a week old baby to vb and want to implement what I've learnt so far.
She wants to be able to put start time, end time and lunch for each...
|
by: rrstudio2 |
last post by:
I am using the following vba code to calculate the median of a table
in MS Access:
Public Function MedianOfRst(RstName As String, fldName As String) As
Double
'This function will calculate the...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |