473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Re: time module methods give an am or pm value ?

dj
Hello again,

Does anyone know which method in the time module will generate and am
or pm ?
If none of the method will do this for me. Can I produce the value on
my own ?
Any suggestions ?
Jun 27 '08 #1
4 1691

"dj" <d.***********@gmail.comwrote in message
news:23**********************************@l42g2000 hsc.googlegroups.com...
Hello again,

Does anyone know which method in the time module will generate and am
or pm ?
If none of the method will do this for me. Can I produce the value on
my own ?
Any suggestions ?
>>from time import *
strftime('%I:%M:%S %p',localtime(time()))
'07:23:24 AM'
>>strftime('%I:%M:%S %p',gmtime(time()))
'02:23:39 PM'

-Mark

Jun 27 '08 #2
dj wrote:
Hello again,

Does anyone know which method in the time module will generate and am
or pm ?
If none of the method will do this for me. Can I produce the value on
my own ?
Any suggestions ?
Read up about strftime (a function, not a method).

Generally, if you know you'll be using something for more than a few
uses, it is worth reading the entire documentation for that module.
People put a fair amount of effort into documentation, and they do it
to reduce the number of questions they have to answer one user at a
time. Reading the results of that effort before asking shows courtesy.
Few people mind explaining unclear documentation when the confusing part
is identified (and they know the answer). Similarly, asking (5000?, a
million?) to each spend a second so you can save an hour is bad economics.

--Scott David Daniels
Sc***********@Acm.Org
Jun 27 '08 #3
dj
On Jun 7, 9:24 am, "Mark Tolonen" <M8R-yft...@mailinator.comwrote:
"dj" <d.a.aberna...@gmail.comwrote in message

news:23**********************************@l42g2000 hsc.googlegroups.com...
Hello again,
Does anyone know which method in the time module will generate and am
or pm ?
If none of the method will do this for me. Can I produce the value on
my own ?
Any suggestions ?
>from time import *
strftime('%I:%M:%S %p',localtime(time()))
'07:23:24 AM'
>strftime('%I:%M:%S %p',gmtime(time()))

'02:23:39 PM'

-Mark
Hello Mark,

Thank you very much. I finally found this function in the
documentation.
Jun 27 '08 #4
dj
On Jun 7, 9:40 am, Scott David Daniels <Scott.Dani...@Acm.Orgwrote:
dj wrote:
Hello again,
Does anyone know which method in the time module will generate and am
or pm ?
If none of the method will do this for me. Can I produce the value on
my own ?
Any suggestions ?

Read up about strftime (a function, not a method).

Generally, if you know you'll be using something for more than a few
uses, it is worth reading the entire documentation for that module.
People put a fair amount of effort into documentation, and they do it
to reduce the number of questions they have to answer one user at a
time. Reading the results of that effort before asking shows courtesy.
Few people mind explaining unclear documentation when the confusing part
is identified (and they know the answer). Similarly, asking (5000?, a
million?) to each spend a second so you can save an hour is bad economics.

--Scott David Daniels
Scott.Dani...@Acm.Org
Hello Scott,

Thank you very much. I did find this function after shortly after I
posted this question.
I appreciated your help :-). And you are right, I do need to be a
better job of checking
the documentation, before I post. Thank you again for your help.
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
14
by: Jay O'Connor | last post by:
Is there a good way to import python files without executing their content? I'm trying some relfection based stuff and I want to be able to import a module dynamically to check it's contents...
18
by: Steven Bethard | last post by:
In the "empty classes as c structs?" thread, we've been talking in some detail about my proposed "generic objects" PEP. Based on a number of suggestions, I'm thinking more and more that instead of...
17
by: Jacob Page | last post by:
I have created what I think may be a useful Python module, but I'd like to share it with the Python community to get feedback, i.e. if it's Pythonic. If it's considered useful by Pythonistas, I'll...
0
by: François Pinard | last post by:
Hi, everybody. I wish someone could advise me. I'm running in circles, trying to find an elegant way to devise run-time pluggable classes. It all goes around method resolution order, I guess....
25
by: Xah Lee | last post by:
Python Doc Problem Example: gzip Xah Lee, 20050831 Today i need to use Python to compress/decompress gzip files. Since i've read the official Python tutorial 8 months ago, have spent 30...
18
by: Max | last post by:
This is a follow-up on my previous thread concerning having the program wait for a certain date and time and then executing some code when it gets there. My question is; can I use the Sleep...
10
by: Bonzol | last post by:
vb.net Hey there, could someone just tell me what the differnce is between classes and modules and when each one would be used compared to the other? Any help would be great Thanx in...
0
ADezii
by: ADezii | last post by:
The motivation for this Tip was a question asked by one of our Resident Experts, FishVal. The question was: How to Declare Default Method/Property in a Class Module? My response to the question was...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.