×

Discussion Board

Results 1 to 3 of 3

Thread: Code help...

  1. #1
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    115

    Question Code help...

    After finally getting the hang of python I have a problem with some code.

    print strftime("%d/%m/%Y", gmtime(d['time']))

    Which gives me a date like 23/02/2008 and now I've trying to create some code where if the date produced equals a date I supply and then run another bit of code. I've got this but it doesn't work :-

    if strftime("%d/%m/%Y", gmtime(d['time'])) == '23/02/2008':
    print 'Correct date'
    #

  2. #2
    Regular Contributor
    Join Date
    Mar 2007
    Posts
    153

    Re: Code help...

    A very basic way is to transform date to a unicode string:
    Code:
    string1 = unicode(time.strftime("%d/%m/%Y",time.localtime()))
    
    if string2 == string1:
          do something

  3. #3
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    115

    Re: Code help...

    Quote Originally Posted by novis View Post
    A very basic way is to transform date to a unicode string:
    Code:
    string1 = unicode(time.strftime("%d/%m/%Y",time.localtime()))
    
    if string2 == string1:
          do something
    Cheers mate. Will give it a go

Similar Threads

  1. Replies: 2
    Last Post: 2007-10-05, 20:40
  2. newbie : code 404 when trying to connect to localhost/test.txt
    By lynx3521 in forum Mobile Java General
    Replies: 3
    Last Post: 2007-09-25, 16:21
  3. Link errors when trying to Display bitmap
    By Bkc82 in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2006-01-16, 22:46
  4. Replies: 0
    Last Post: 2003-09-26, 15:07

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •