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
-2
votes
2 answers

How to format a date with parentheses

I want to format my date like : From May 1 (10:02 pm) to May 3 (10:02 pm) so I have this code: Time.ToLocalTime().ToString("MMM. d, (h:m tt)") Will this work? Time is a regular DateTimeOffset variable in this case...
-2
votes
1 answer

Constructing DatetimeOffset object based on Ticks giving incorrect value

I have DatetimeOffset value stored as below in my database table : 2002-08-27 07:49:20.3190000 -11:00 Now this is how i write this value in a binary file : DateTimeOffset d = "2002-08-27 07:49:20.3190000 -11:00"; BinaryWriter w…
I Love Stackoverflow
  • 6,738
  • 20
  • 97
  • 216
-2
votes
1 answer

How to Convert UTC DateTime to Different Time zone DateTimeOffSet during DayLightSavingTime Enable using c#

I got the Date and time(utc time) from database and i need to convert to cst timezone. I tried following code but its not convert date and time. DateTimeOffset returnTime = TimeZoneInfo.ConvertTime(time, timeZone); Input time = {3/11/2018 3:24:19…
-2
votes
1 answer

Real Date and Time

I have an audit trail where the date and time of user's time in / time out was enlisted. Is it possible that even I changed the system date and time. It ignores the system date/time that I have changed and log the real date and time of time in/ time…
Jet Seighart
  • 29
  • 1
  • 6
-2
votes
2 answers

JavaScript/jQuery - Convert from 24 Hr Datetime String to 12Hr Date format?

var timeZone ="CDT" var startDateTime = "2016-06-15 22:30:00.0"; this.outDate = function() { return getJustTime(startDateTime,timeZone); } function getJustTime(startDateTime,timeZone) { outDt =…
JsLearner
  • 109
  • 1
  • 5
  • 16
-2
votes
2 answers

How to make hour, minute offset flags in C programming

I am using C on Unix. The program displays the time and I am trying to figure out how to offset the current time in minutes and hours. This part of the code while ( ( let = getopt(argc, argv, "alo:vh")) != -1 ) { switch (let) { case 'o': …
Meg
  • 7
  • 2
-2
votes
1 answer

In Go, given a location name, how can we determine the current time in that location?

We can't use the offset returned by Zone(): package main import "fmt" import "time" func main() { loc, _ := time.LoadLocation("America/Los_Angeles") t := time.Date(2015,04,12,19,23,0,0,loc) t2 := time.Date(2015,03,1,19,23,0,0,loc) …
miguelv
  • 2,856
  • 1
  • 25
  • 24
-2
votes
1 answer

What does DateTimeOffset.Now.Offset.ToString() return when in daylight savigs time in the UK

so I know the function DateTimeOffset.Now.Offset returns the offset from UTC and from wikipedia it states that GMT and UTC are the same. Therefore I would guess that DateTimeOffset.Now.Offset.ToString() would always return 00:00:00 if your timezone…
JKennedy
  • 18,150
  • 17
  • 114
  • 198
-3
votes
1 answer

How to get only the time difference, ignoring the date difference, between two DateTimeOffset in C#?

i am using c# and I need to get the difference between two DateTimeOffset() ignoring the year, month and day witch mean get the difference between the hour, minutes and the seconds. lets say this is my start date "startDate":…
han na
  • 7
  • 2
-3
votes
2 answers

how to add 30 min to date values in sql so they change correctly?

there is a timepair table. It has columns : start_pair end_pair 08:30:00 09:15:00 I need to shift it by 30 min - how to do it? 8:30 becomes 9:00. update set start_pair = date(start_pair) + minute(30)
ERJAN
  • 23,696
  • 23
  • 72
  • 146
-3
votes
1 answer

Convert date time in another timezone with offset value in ruby

I am fairly new to ruby. I have a date value say "2014-12-15T19:56:59Z" and an offset value say "-06:00". How can I convert the given date time in the timezone given by offset value.
Akshay
  • 153
  • 3
  • 14
-3
votes
1 answer

What is the right ToString(format) for DateTime(Offset) for the following?

There's a ton of articles on this but I can't find exactly what I am looking for. I want to match what Java does so I think I need: DateTime Kind=unknown => 2020-07-08T02:03:04 DateTime Kind=UTC => 2020-07-08T02:03:04Z DateTime Kind=local =>…
David Thielen
  • 28,723
  • 34
  • 119
  • 193
-4
votes
1 answer

How convert PST Unix timestamp to UTC?

How convert PST Unix timestamp to UTC and then to any custom time zone (GMT+2, ...) ? Please provide solution in javascript or nodejs lib (momentjs)
Oleg Dats
  • 3,933
  • 9
  • 38
  • 61
1 2 3
40
41