timezone

Handling time zones in Cocoa

五迷三道 提交于 2019-12-11 14:49:36
问题 I just want to clarify if I am understanding how dates & time zones work. Basically, I have a date string @"2008-07-06 12:08:49" that I want to convert to an NSDate. I want this date and time to be in whatever the current user's time zone is set in. So if they are in GMT or HST, it's still 12:08:49. If I have date in unix form 1215382129 (UTC) and my time zone is set to London (GMT), the outputted date from NSLog() is: 2008-07-06 12:08:49 +0100 If I then change my time zone to Hawaii (HST)

Handling time-zone between client and server for date-only DateTime

别来无恙 提交于 2019-12-11 14:49:28
问题 I have a custom validation attribute in my ASP.NET Web API application that checks if the date is in the future or not (dates in the future are not allowed). Here's the code: protected override ValidationResult IsValid(object value, ValidationContext validationContext) { if (value != null) { var date = (DateTime)value; if (date != null) { if(date.Date > DateTime.UtcNow.Date) { return new ValidationResult(FormatErrorMessage(validationContext.DisplayName), new[] { validationContext.MemberName }

Date time conversion from timezone to timezone in sql server

徘徊边缘 提交于 2019-12-11 14:47:19
问题 I having an column of UNIX time stamp in my database table, which comes from a system that is in the Kuwait time zone. My database server's time zone is Eastern Time US & Canada . Now I need to convert the UNIX time stamp in to Kuwait time zone date value using an SQL query. Can anyone tell me how I can convert this UNIX time stamp into a Kuwait time zone date value? 回答1: Unix timestamps are integer number of seconds since Jan 1st 1970 UTC. Assuming you mean you have an integer column in your

TimeStamp.valueOf() method

不羁的心 提交于 2019-12-11 14:35:25
问题 public static void main(String[] args) { Timestamp ts = new Timestamp(116, 02, 12, 20, 45, 0, 0); Date d = new Date(); d.setTime(ts.getTime()); System.out.println(d); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); //System.out.println(ts.getTime()); System.out.println(simpleDateFormat.format(ts)); System.out.println(Timestamp.valueOf(simpleDateFormat.format(ts))); } In above code last two lines print

Server side changes date/time sent by client

扶醉桌前 提交于 2019-12-11 14:24:25
问题 I'm facing the following problem, I have a play application with angular and java. In one page the client selects in a calendar some date and time for example 2015-04-03 15:00 this data is put in a javascript object as a Date and later this data is submit to my server but it seams the server is converting this date/time to his timezone saving 2015-04-03 16:00 instead of 15:00 as the client side sent. After I submit the data to the server where is persisted in the database when I reload the

Issue with inDaylightTime() and determing if a date is in daylight savings time

落爺英雄遲暮 提交于 2019-12-11 14:15:14
问题 Have been beating my head against this and not sure what I'm doing wrong here. I am testing out the inDaylightTime() method for a certain time zone but it is returning "false" when it should be returning "true" in this case. import java.util.TimeZone; import java.util.Date; public class TimeZoneDemo { public static void main( String args[] ){ Date date = new Date(1380931200); // Sat, 05 Oct 2013, within daylight savings time. System.out.println("In daylight saving time: " + TimeZone

Rails change default timezone

偶尔善良 提交于 2019-12-11 14:09:38
问题 I'm trying to change default timezone in Rails 3.2.8 app to GMT+04:00, but I don't know how to do it. The following solutions do not work for me: config.time_zone = 'Moscow' config.time_zone = "(GMT+04:00) Moscow" config.active_record.default_timezone = 'Moscow' config.active_record.default_timezone = :local Also I've tried in rails console the following: ActiveSupport::TimeZone.all.map(&:name) wich returned a list of values, including "Moscow" . Time.zone returned (GMT+00:00) UTC wich is not

Display html content between defined hours mon to friday

丶灬走出姿态 提交于 2019-12-11 14:06:28
问题 i was wondering if there is a quite simple solution to display content between certain hours and only during working days in a Europe timezone? The hours will be everyday (except weekends) between 9AM and 5PM, between those times a html content should be shown. If possible a different html content from 5PM till 9AM. 回答1: The short version is that you use new Date() to get the current date/time, and then you use DOM manipulation to add/remove that content as appropriate. If you want content to

How to set timezone for SQL?

萝らか妹 提交于 2019-12-11 14:04:49
问题 I'm using SQLite for my cgi application, but the timezone I'm in is different from that of the shared server this stuff is running on. Can I set my timezone somehow in SQLite so I don't need to mess up my application with time conversions and I can use things like NOW() in my SQL? If not: what are my other options? 回答1: SQLite doesn't have a way to set the connection time zone because it's targeted towards embedded database uses--whatever you use to change your C library localtime() output

Searchlogic doesn't convert the time properly for datetime conditions

怎甘沉沦 提交于 2019-12-11 14:03:28
问题 The author of Searchlogic says that it is delegated to A::R converter, but at least in our case this didn't cover the usual cases. Local time was 'interpreted' as UTC and therefore was moved by one hour (CET). How can I do that properly? I add our current workaround as an answer, hopefully it helps somebody! 回答1: We've added the following method to the application controller: protected def parse_datetime_fields(hash, key) value = hash[key] return unless value hash[key] = Time.zone.parse(value