Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 3rd, 2003, 11:05 AM
penngray penngray is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 38 penngray User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 52 m 31 sec
Reputation Power: 6
date function question

I would like to add 12 hours to a the current date...

1) I dont even know what to call to get current date....

date()??? I know I can import time and do time.time() to get a time value but what do I import ?? to utilize a "date()" function.

2) Once I know how to get a current date into a local variable. How do I increment that date by 12 hours.

thanks
Penngray

Reply With Quote
  #2  
Old October 3rd, 2003, 11:23 AM
penngray penngray is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 38 penngray User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 52 m 31 sec
Reputation Power: 6
version 2.2.3 of python

Reply With Quote
  #3  
Old October 3rd, 2003, 01:14 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,536 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 3 m 4 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
Obviously you've discovered the time module.. in python 2.3 you could have also used the timedate module . Anyway give this a try

>>> import time
>>> time.localtime()
(2003, 10, 3, 18, 43, 29, 4, 276, 1)
>>> time.strftime('%a, %d %b %Y %H:%M:%S', time.localtime(time.time() + 43200))
'Sat, 04 Oct 2003 06:59:55'

Ok so we know there are 60 seconds in a minuite, so if we multiply that by 60 we get the number of seconds in an hour (3600). If we then times that by the number of hours we want to add to the time we get 43200. Then we can add that to the current time and use the strftime() function to format the new time

Have fun,
Mark.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > date function question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT