utc

Django DateTimeField from form to UTC

☆樱花仙子☆ 提交于 2019-12-12 11:14:02
问题 I have a small Django app with a form, wich saves some data to the DB. Here's the form: class SomeForm(forms.Form): time = forms.DateTimeField() ... And the view, where I save it: class AccountAddIncome(View): def save(self, form): model = Model( time=form.cleaned_data['time'] ) model.save() def post(self, request, *args, **kwargs): form = SomeForm(request.POST) if form.is_valid(): self.save(form) return redirect(self.success_url) else: ... My problem is, that the Django admin says: "Note:

How to manage timezones in a web application?

寵の児 提交于 2019-12-12 10:57:23
问题 I wan't to manage the different timezones of my users in my web application, but I have no idea where to start. I have to save the local time of each user in my database?, or maybe make the conversion to a UTC time, save it, and then make the conversion again to show it?, or there is another way? For example, if one of my users make an appointment in his local time, I have to convert it to UTC store it in my database, and then when he need it, convert it again to his local time an show it??

Convert a date and time string according to UTC format

邮差的信 提交于 2019-12-12 10:30:52
问题 I am having a date string 2012-11-21 13:11:25 which I get from local database. I have to convert this according to UTC settings and display it on a particular screen. So if its GMT+05:30 it should be displayed as 2012-11-21 18:41:25 on the screen. How can I do this conversion. I have checked some of the questions but that didn't work out. I am able to get a Date object that returns something like Wed Nov 21 13:11:25 GMT+05:30 2012 after this I need to get the time as 18:41:25 and date as 11

Using TimeZones on website using ASP.Net 3.5 / SQL Server 2005

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 09:23:21
问题 I am trying to determine, how I should implement local time in a web-app. All users are logged in, there are no anonymous users. They will need to see all time-values in their local time. Is this how it should be done? All DateTime values are saved as UTC-time in database Each user has a UTC-Offset value stored in his profile When displaying a datetime-value, I take the value from the database, and apply the users offset. Is this the way to go? Or am I missing something? 回答1: Don't store a

Getting current date in milliseconds (UTC) (NO use of strings)

寵の児 提交于 2019-12-12 08:22:46
问题 Well, you might think that this question has already been asked, but I think it has not. The solutions I've read about all had this "jigsaw puzzle" technique (like getUTCMonth() + getUTCMinutes + ... ). But as I only want to compare the elapsed seconds between two UTC (!) dates, this does not apply. As everybody knows, you can get the current (non-UTC) date by: var d = new Date(); var t_millis = d.getTime(); But this is NOT what I want. I'd like to have the current system date in UTC and in

How to parse a UTC epoch 1352716800 to NSDate?

孤者浪人 提交于 2019-12-12 04:46:11
问题 I'm reading data from a XML file which has a UTC date looking like "2011-05-04T00:00:00", and a UTC epoch looking like 1352716800. Parsing the UTC epoch to NSDate would probably be much safer than messing around with a complex date format. How would I parse the UTC epoch to NSDate? With NSDateFormatter and a special format for "UTC Epoch"? I think that it is [[NSDate alloc] initWithTimeIntervalSince1970:epoch] and a test seemed to work. But I am not sure if that's just correct by accident or

Java:Convert date in UTC to local time zone

。_饼干妹妹 提交于 2019-12-12 04:31:12
问题 I have date which is stored in db in UTC timezone. have to convert this date to systems local timezone. I'd looked into all other questions in stackoverflow but non of them works for me. Please can any one help me with this. I need output in java.utils.Date only as startAt() method of quartz scheduler accepts Only Date. 回答1: tl;dr You do not need to apply a time zone. Details A Date already has a time zone: UTC. It represents a specific moment, a point on the timeline. You would only apply a

Node + Mongodb + ISODate + Timezone issue

笑着哭i 提交于 2019-12-12 04:25:44
问题 Hello I am working in node js + mongodb. When I insert the data into collection the data is stored default ISODate eg. ISODate("2016-06-17T13:00:21.665Z") I want to insert the date fields should be store in UTC. Its already stored in UTC format or need to change anything in code ? Please anyone suggest me. My Code: var query = {}; query.created_by = 'admin'; query.created_on = new Date(); var collection = mongoUtil.list; collection.insert(query, function(err, item) { if (!err && item) {

Joda Time - Convert UTC DateTime to Date - Using a Version 1.2.1.1 of Joda

自古美人都是妖i 提交于 2019-12-12 03:23:49
问题 Good morning everyone. I'd like to help you to see how I can accomplish the conversion of a org.joda.time.DateTime to java.util.Date using the 1.2.1.1 version of Joda Time. Why Joda 1.2.1.1 ? Because currently I can only work with this version of Joda "unfortunately". My Test> System.out.println("JODA Version : 2.8.2 - UTC TIME to Date " + new DateTime().withZone(DateTimeZone.UTC).toLocalDateTime().toDate());; System.out.println("JODA Version : 1.2.1.1 - UTC TIME to Date " + new DateTime()

Calling `new Date(long)` results in “Jan 01 01:00:00 CET 1970”? [duplicate]

回眸只為那壹抹淺笑 提交于 2019-12-12 02:57:16
问题 This question already has answers here : Epoch is not epoch if do a new Date(0L). Why? (4 answers) Closed last year . The Java doc describe that the constructor Date(long date) constructs a Date object using the given milliseconds time value since January 1, 1970, 00:00:00 GMT When I did new Date(0) , the date is Jan 01 01:00:00 CET 1970 I don't know why it begin with 01h 回答1: It's show 1AM because you're an hour ahead of GMT. A date instance is simply a counter of the number of milliseconds