Questions tagged [datetimeoffset]

DateTimeOffset is a data structure that encapsulates a DateTime value and the Offset from UTC that the value reflects. It is used to represent an instantaneous moment in time, while still capturing the perspective of the observer.

DateTimeOffset is a data structure that encapsulates a DateTime value and the Offset from UTC that the value reflects. It is used to represent an instantaneous moment in time, while still capturing the perspective of the observer.

Contrary to popular belief (and to much of the documentation) the offset provided does not represent a time zone. One might start with a time zone to obtain the offset, but it is a one-way function. You can not determine the time zone by the offset alone. For a better understanding of this, see this community wiki answer.

The preferred serialization format for this type of data is defined as part of the ISO-8601 specification.

  • Example: 1997-07-16T19:20:30+01:00

DateTimeOffset and similar structures are presented in:

Please update this list if you are aware of similar structures in other languages, frameworks, or databases

614 questions
0
votes
1 answer

SQL Server rows per minute

I'm sorry, I couldn't come up with a better title. I have a table that has a row inserted every time someone hits my JSON api. In essence it has 2 columns, Ipaddress (nvarchar) and date (datetimeoffset). Part of my problem is, I'm not sure exactly…
Erick
  • 853
  • 8
  • 17
0
votes
2 answers

Rails localtime returns wrong time zone

I have a problem where when saving a datetime attribute, the form returns -04:00 instead of -05:00 Using Rails 3.2.3 In application.rb: config.time_zone = 'Eastern Time (US & Canada)' Using MySQL with mysql2 adapter Running…
0
votes
1 answer

How can I configure ASP.NET web service to only send LocalDateTime property of DateTimeOffset object as JSON?

I have a bunch of entity class (generated by Linq to SQL) with a few DateTimeOffset properties in it. When I send that over the wire as JSON from a .asmx web service, the JSON serializer generates the following…
Egil Hansen
  • 15,028
  • 8
  • 37
  • 54
0
votes
0 answers

User-friendly time zone names in Symfony2

When Symfony2 renders a form input of type "timezone", it uses the names from the time zone database (e.g. "America/Los Angeles") for both the option values and the display. Is there a way to display a more user-friendly name for each zone (for…
Alf Eaton
  • 5,226
  • 4
  • 45
  • 50
0
votes
1 answer

Rails change default timezone

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)…
0
votes
1 answer

confusion around DateTimeOffset and TimeZones

I am currently developing a .net application that will be used in multiple different countries and time zones. The back end database is sql server. I have been looking in to the datetime, datetime2 and datetimeoffset data types and I am a little…
amateur
  • 43,371
  • 65
  • 192
  • 320
0
votes
2 answers

Ruby - new_offset losing a second

I'm not sure if this behaviour is intended, but it seems a bit weird to me. I'm using the code from How do you get DateTime.parse to return a time in your time zone? require 'date' estHoursOffset = +10 # Brisbane/Australia estOffset =…
Alex Ghiculescu
  • 7,522
  • 3
  • 25
  • 41
0
votes
2 answers

How do you store DateTimeOffset in a SQL Server DateTime field

This is in C# I'm consuming data from an RSS feed and want to store the data in our database. The problem that I'm having is how to store the LastUpdateTime. XmlReader reader = XmlReader.Create(uri); SyndicationFeed rssFeed =…
John
  • 3,332
  • 5
  • 33
  • 55
0
votes
1 answer

Change the offset alone in a JodaDate without changing the date and time information

I get a String like this "2012-07-01T06:00 +02:00" as input. It is in CET. But this String should have been "2012-07-01T06:00 +01:00". We can't change anything on the original source. Now I want to get that Date as "2012-07-01T06:00 +01:00" expected…
0
votes
1 answer

Fatal error: Undefined class constant 'PER_COUNTRY'

I'm Trying to find Timezone for a Country by Using Below Code. // FIND TIMEZONE CODE FROM COUNTRY CODE HERE // COUNTRY CODE SHOULD BE IN ISO2 FORMAT $country_code = 'GR'; $arr_new_timezone = …
pinaldesai
  • 1,835
  • 2
  • 13
  • 22
0
votes
2 answers

Datetime and offsets in .net

How can I schedule a background job to start every day at 9pm in Colombian time? Im using quartz.net public class Program { static void Main(string[] args) { // construct a scheduler var schedulerFactory…
nacho10f
  • 5,816
  • 6
  • 42
  • 73
-1
votes
1 answer

I am getting error while update-database command to make tables related to Identity. column parameter or variable:cannot find data type datetimeoffset

I try to update the database to make tables related to Identity, and I'm using Microsoft.AspNetCore.Identity, autogenerated public class IdentityUser, when I write the command, I recieve this error: Column, parameter, or variable #14: Cannot find…
-1
votes
1 answer

How to convert date string which contains time offset to another format?

I'm receiving this kind of string as date "2020-09-09T12:41:41 -04:00". It seems like this string contains time offset. I need to convert this to "3/15/2020, 1:23:09 PM " format. How can I achieve this? I tried to create new Date object with that…
-1
votes
1 answer

C# How to DateTimeOffset.Parse 2022003023T05:57:44.200Z?

I tried DateTimeOffset dto = DateTime.ParseExact("2022003023T05:57:44.200Z", "yyyyMMMMdd'T'HH':'mm':'ss'.'fff'Z'", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal); but to no avail: 'String '2022003023T05:57:44.200Z' was not recognized…
Kok How Teh
  • 3,298
  • 6
  • 47
  • 85
-1
votes
1 answer

How can I change date formats "2022-06-04T00:00:00.000Z" to "1525844100000" for react highcharts

I've the following date: "2022-06-04T00:00:00.000Z" format, We've need of date calculation for highcharts in this numeric type format "1525844100000" so how can I calculate in react-highcharts xAxis: { type: 'datetime', ordinal: false, …