Hi
I am confused about the timezone setting. I have my OS timezone set to
'Asia/Shanghai', and my MYSQL/Mariadb is also using 'Asia/Shanghai'
timezone. So i tried to configure the timezone in DJANGO settings.py
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_L10N =
This worked:
import datetime
Then, use 'datetime.datetime.now()' instead of 'datetime.now()'
Thanks guys!
On Jul 14, 11:57 am, Subhranath Chunder <subhran...@gmail.com> wrote:
> How did u import the datetime module?
> If you did:
>
> a>
> import datetime
> Then,
How did u import the datetime module?
If you did:
a>
import datetime
Then, use 'datetime.datetime.now()' instead of 'datetime.now()'
b>
from datetime import datetime
Then 'datetime.now()' should work correctly.
Thanks,
Subhranath Chunder.
On Wed, Jul 14, 2010 at 9:13 PM, Chris M
This code works fine for me:
In [1]: from gallery.models import Gallery
In [2]: g = Gallery.objects.all()[0]
In [3]: g.created_at
Out[3]: datetime.datetime(2010, 4, 1, 7, 11, 51)
In [4]: import datetime
In [5]: n = datetime.datetime.now()
In [6]: g.created_at > n
Out[6]: False
In [7]:
On Jul 14, 4:43 pm, Chris McComas wrote:
> This is my model, I'm trying to set it so that if the game is in the
> future, based on the field date, then to return True, if not return
> False.
>
> http://dpaste.com/218111/
>
> I am importing datetime in my models.py but for
This is my model, I'm trying to set it so that if the game is in the
future, based on the field date, then to return True, if not return
False.
http://dpaste.com/218111/
I am importing datetime in my models.py but for some reason it's
giving me nothing. I tried displaying future and nothing
Thanks a lot guys :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to
That will work, as long as the parent doesn't need to go back into a
native object easily - if s/he needs to easily get back into a
datetime object, use pickle:
import pickle
import base64
toEncode = pickle.dumps(datetime.now())
encoded = base64.encodestring(toEncode)
decoded = base64
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
convert it to a string: str(datetime.now())
Luke
luke.seelenbin...@gmail.com
"I [may] disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
Asinox wrote:
> hi guys, i want to encrypt the
hi guys, i want to encrypt the "datetime.now()" , im try with base64
but base64 need string... how ill encrypt ?
Thanks :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
T
re due, like so:
>
> from datetime import datetime
>
> current_banners = Banner.objects.filter(show_from__lte =
> datetime.now())
>
> However, the server is not in the same time zone as the people editing
> the site, so the timing's off by the time delta between the two.
>
I have a Banner model with a show_from DateTimeField, which I filter
to make sure I'm only showing them after they're due, like so:
from datetime import datetime
current_banners = Banner.objects.filter(show_from__lte =
datetime.now())
However, the server is not in the same time zone
models.TextField("Comments", maxlength=1000)
> etc...
>
> def save(self):
> self.comments += "This is a string - " + datetime.now() + "
> This is a string "
>
>
>
> Whenever, I save my order class I get t
try datetime.now().__str__() or if you want to make it pretty try
datetime.now().strftime(YourCustomFormatHere). Look at
http://docs.python.org/lib/strftime-behavior.html#strftime-behavior
Your problem is a datetime object is a not a string. Both those above
examples turn it into a string
save(self):
self.comments += "This is a string - " + datetime.now() + "
This is a string "
Whenever, I save my order class I get the following error:
TypeError at /admin/plush/order/1/
cannot concatenate 'str' and 'datetime.date
How can I get the current time in a way that respects the time zone I've
set in Django settings?
Or, alternatively, how do I convert a string like 'America/New York'
into a timezone object?
Thanks,
Todd
--~--~-~--~~~---~--~~
You received this message because
Thanks Luke, very nicely explained!
Rudolph
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group,
17 matches
Mail list logo