displaying date problem

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Feb 2009
Posts: 9
Reputation: apollo1492 is an unknown quantity at this point 
Solved Threads: 0
apollo1492 apollo1492 is offline Offline
Newbie Poster

displaying date problem

 
0
  #1
Feb 12th, 2009
i need to be able to have python spit out a date like this (mm/dd/yyyy) even if the user doesnt add the "/" to there input. here is what i got so far.

import string
date = raw_input(enter your date:")
print date[0:2]+'/',date[2:4]+'/',date[4:8]

the output is mm/ dd/ yyyy.

how would you go about getting rid of the blank spaces in front of dd and yyyy?
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,027
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 932
Moderator
vegaseat's Avatar
vegaseat vegaseat is online now Online
DaniWeb's Hypocrite

Re: displaying date problem

 
0
  #2
Feb 13th, 2009
Replace the commas by plus.
What do you expect the user to enter? You may want to give some kind of a templet/hint in your prompt.
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 48
Reputation: yilmazhuseyin is an unknown quantity at this point 
Solved Threads: 5
yilmazhuseyin's Avatar
yilmazhuseyin yilmazhuseyin is offline Offline
Light Poster

Re: displaying date problem

 
0
  #3
Feb 13th, 2009
I would assign your date variable into a date type variable (I think it was something like datetime just look it up). so you will have a real date. then you can easiliy format your out put.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC