Kodi Community Forum
How get simple 'today' date string ? - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26)
+--- Thread: How get simple 'today' date string ? (/showthread.php?tid=174213)



How get simple 'today' date string ? - realtebo - 2013-09-24

I know there is a lot of online doc about python and dates, like this official doc page. but I'm asking this to you because I'm new to Python and because Python version declared from addon.xml is as low as 2.1.0. ...

What's the right way, in python 2.1 to get the current date and create a simple string like "2013/9/24" ?


RE: How get simple 'today' date string ? - Martijn - 2013-09-24

python 2.1.0 is our internal "version".
we actually use python2.6 and some use python2.7

Simple search:
http://www.saltycrane.com/blog/2008/06/how-to-get-current-date-and-time-in/


RE: How get simple 'today' date string ? - realtebo - 2013-09-24

So 2.6 is the 'safe' version ?
I tried the method from the lilnk under windows 8 and all works, must I test againsta all supported platoform or can I suppose it works ?


RE: How get simple 'today' date string ? - Martijn - 2013-09-24

if it works for you it should work for others as windows (for now) uses 2.6.x
once done create a thread for others to test you plugin and watch feedback come in if some experience problems.


RE: How get simple 'today' date string ? - sphere - 2013-09-24

To avoid possible locale issues (not sure if the timezone etc. is always correct in the python environment, especially on embedded hardware like raspberry pi, OpenElec or Android) I would suggest using XBMC InfoLabels for the date.

If you just need the date of today (as string), you can use something like:
PHP Code:
today xbmc.getInfoLabel('System.Date(dd.mm.yyyy)')
today_other_format xbmc.getInfoLabel('System.Date(yyyy/mm/dd)'

Just have a look to the available infolabels and their format options.


RE: How get simple 'today' date string ? - realtebo - 2013-09-24

Thanks.

I'm testing on android, windows, linux, and raspberry.

If everything works, I'll keep date function; they're more readable, just this.