Hello!
I am using the wx.DatePickerCtrl to ask for the date using this code

wx.DatePickerCtrl(panel, -1, size=(110, -1), style=wx.DP_DROPDOWN | wx.DP_SHOWCENTURY)

However, it returns the result as

Mon 30 Aug 2010 12:00:00 AM CEST

but I meet them to be as YYYY/MM/DD. Is there any way to do it?
Cheers!

Dani

Thanks, I'll check it. I have another problem. I realized that it actually the wx.DatePickerCtrl returns the current system date, but it actually does not update to the selected date. How can I solve it?
Cheers,

Dani

I managed to get it (code at the end). However, I get the date printed twice. I also checked your hint to set the time format. However, if I do

print time.strftime("%y/%d/%m", self.Day)

I get this error

TypeError: argument must be 9-item sequence, not DateTime

Cheers!

import wx, MySQLdb,  time
class DayDataDlg(wx.Frame):
	def __init__(self, parent, id, title = 'Enter day data'):
		wx.Frame.__init__(self, parent, id, title, size=(800,650))
#Define main panel
		panel = wx.Panel(self, -1)
		vbox = wx.BoxSizer(wx.VERTICAL)
	#Define sizers
		#Horizontal sizers
		hbox1 = wx.BoxSizer(wx.HORIZONTAL)
	#Define day data fields
		DateTXT = 	wx.StaticText(panel, -1, 'Date:', size=(35, -1))
		self.dpc = wx.DatePickerCtrl(panel, -1, size=(110, -1), style=wx.DP_DROPDOWN | wx.DP_SHOWCENTURY)
		self.Bind(wx.EVT_DATE_CHANGED, self.OnDateChanged, self.dpc)
	#Add fields to sizers
		hbox1.Add(DateTXT, 0, wx.ALL, 5)
		hbox1.Add(self.dpc, 0, wx.ALL, 5)
		vbox.Add(hbox1, 0, wx.ALIGN_LEFT | wx.ALL, 5)
		panel.SetSizer(vbox)
		self.Centre()
		self.Show(True)
	def OnDateChanged(self,evt):
		self.Day = self.dpc.GetValue()
		print self.Day
app = wx.App()
DayDataDlg(None, -1)
app.MainLoop()
This article has been dead for over six months. Start a new discussion instead.