Completed
Last Updated: 15 Aug 2022 10:23 by ADMIN
Steve
Created on: 11 Apr 2013 21:26
Category: Date/Time Pickers
Type: Feature Request
104
Support binding of DateTimePicker to type DateTimeOffset
Globalized applications use the DateTimeOffset type instead of DateTime since it includes the offset from UTC for different time zones. If DateTimePicker could bind to this type it would simplify UI development. It would have to have the offset or timezone value provided as either a property or as a second binding.
19 comments
ADMIN
Viktor Tachev
Posted on: 15 Aug 2022 10:23

Hello Marcus,

While researching the issue we found that there is no one-size-fits-all solution. If we were to add this as a built-in feature the dates had to be forced to use a very specific format. However, this would not work for everyone as we are aiming to make the components usable in various scenarios. Because of this the recommended approach is to use AutoMapper. That would enable you to use the date format that works best in your scenario. 

 

Regards,
Viktor Tachev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Marcus
Posted on: 08 Aug 2022 11:11
It took you 7 years to come up with an official "solution" for this problem, and all you could manage was "use automapper"? (which btw doesn't solve the issue)

Seriously?
Mark
Posted on: 15 Sep 2020 19:03

Sorry for confusion...

[Deadline] [datetimeoffset](7) NULL

should be

[MyDate] [datetimeoffset](7) NULL

Mark
Posted on: 15 Sep 2020 19:01

I know this is an old post but this worked for me.

// *** TSql ***

CREATE TABLE [dbo].[MyTable](
[Id] [int] IDENTITY(1,1) NOT NULL
, [Deadline] [datetimeoffset](7) NULL
 CONSTRAINT [PK_Task] PRIMARY KEY CLUSTERED 
(
[Id] ASC
) WITH (STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

GO

CREATE PROCEDURE [dbo].[UpdateDate] (@Id INT, @DateParam NVARCHAR(50))

BEGIN

    SET NOCOUNT ON;

    BEGIN TRY

        BEGIN TRANSACTION;

            DECLARE @DateOffset DATETIMEOFFSET = CAST(@DateParam AS DATETIMEOFFSET(7))

            UPDATE [dbo].[MyTable] SET [MyDate] = @DateOffset WHERE [Id] = @Id

        COMMIT TRANSACTION;

    END TRY

    BEGIN CATCH

        IF @@TRANCOUNT > 0 ROLLBACK TRANSACTION;

    END CATCH

END

 

// *** js ***

$("#datetimepicker").kendoDateTimePicker({
    value: new Date()
    , change: function(e) {

        $.ajax({
            url: "/api/UpdateDate"
            , type: "POST"
            , data: JSON.stringify({
                "Id": << record id here >>
                , "Deadline": toDateTimeOffset(kendo.parseDate(this.value()))
            })
            , success: function(result) {
                alert("Update Successful");
            }
            , error: function(result) {
                alert(result.error);
            }
        });
    }
});

/**
 * converts a datetime to a datetimeoffset format for ms sql insert
 * @param {date} dateTime
 */
function toDateTimeOffset(dateTime) {
    var dateStr = kendo.toString(kendo.parseDate(dateTime), "MM/dd/yyyy hh:mm:ss");
    var tzOffset = (dateTime).getTimezoneOffset();
    var tzOffsetHour = tzOffset/60;
    var tzOffsetMins = tzOffset % 60;
    var tzOffsetStr = (tzOffsetHour >= 0 ? "+" : "-") + zeroPadNumber(tzOffsetHour, 2) + ":" + zeroPadNumber(tzOffsetMins, 2);
    return (dateStr + " " + tzOffsetStr);
}

/**
 * zero pad a number as a string to a minimum length
 * @param {number} num
 * @param {number} len
 */
function zeroPadNumber(num, len) {
    var s = "" + num;
    if (s.length >= len)
        return s;
    s = "000000000" + s;
    return s.substr(s.length - len);
}

ADMIN
Viktor Tachev
Posted on: 23 Jun 2020 14:19

Hello,


We have prepared an example illustrating how DateTimeOffset values can be handled.

 

Regards,
Viktor Tachev
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
ADMIN
Maria Ivanova
Posted on: 06 Dec 2019 16:12

Hi everyone,

We understand that this is important functionality and we are actively looking at the suggested option to bind DateTimePicker to a datetimeoffset.

We would appreciate if you share with us use cases where you would use the DateTimePicker  with datetimeoffset. What presentation of the "offset" part would work best for these scenarios?  Also regarding the values posted to the server - would you need to post datetimeoffset or you would need UTC date + offset separately, or you would need both. Sharing such details with us will help us better understand your needs and come up with a  feature that really works for you.

Kind Regards, Maria Veledinova Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Imported User
Posted on: 07 Aug 2018 21:17
Telerik,  Do we have any update on this?
Entropy69
Posted on: 20 Mar 2018 11:14
DateTimeOffset was suggested as way to go back in 2012, please implement datetimeoffset support! 
https://blogs.msdn.microsoft.com/davidrickard/2012/04/06/datetime-and-datetimeoffset-in-net-good-practices-and-common-pitfalls/
Tom
Posted on: 26 Jan 2018 00:11
Microsoft state that DateTimeOffsets should be used instead of DateTimes in almost all situations.  On that basis all of the Telerik controls really should support this out of the box.  It's been years since this was raised as an issue, a fix is long overdue.
Dennis
Posted on: 13 Nov 2017 13:56
I also think there should be some kind/level of support too - even if it's only a utility function to assist, as otherwise the DatePicker control is useable (- without a manual work-around)..

(It's sad that this is the first time I'm trying to use the control & already it's fallen-over at the start-line.)
Gavin
Posted on: 03 Oct 2017 10:21
Hi,

Do you have this planned for any known release?

Thanks,
Gavin
Mark
Posted on: 14 Jul 2017 11:45
What is the delay? Get on with it!
Brian
Posted on: 30 May 2017 21:21
I was getting ready to recommend we make a purchase of Kendo.. assuming that the OData support would be OOTB...

I understand why a software shop might hesitate -- since Microsoft has kinda revamped OData versions willy-nilly.. and then only supported the standard in their API libraries, sub-par, themselves, for some time.

However, putting Odata aside, consider that the DateTimeOffset SQL data type has been a while around some time now and was actually Microsoft's recommended date structure for greenfield application development.
Loren
Posted on: 14 Jan 2016 18:35
I would like to request that the DateTime Pickers support UTC and DateTimeOffset. The value recieved should be converted to the clients timezone/offset for display purposes and on the backend have a hidden input for the UTC version to post to the server
ADMIN
Telerik Admin
Posted on: 02 Sep 2015 09:10
Thanks for the feedback, folks. We'll have this on our radar for the future releases of the DateTimePicker widget.
Casimodo
Posted on: 01 Sep 2015 22:13
My date-times are all DateTimeOffsets. Can't use Kendo MVC helpers for any time related properties.
The request for this feature is over two years old, still no progress.
Imported User
Posted on: 18 Feb 2015 17:43
I would love this feature. 

Is the limitation how JavaScript handles UTC? If so, then maybe http://momentjs.com/timezone/ would be useful.
Cemil
Posted on: 18 Nov 2014 21:55
I totally agree with that. In my opinion not only in DateTimePicker but also in all DateTime related portions of Kendo UI like Grid binding and column filtering, DateTimeOffset type should be supported.
Алексей
Posted on: 20 May 2014 16:10
Yes! Very much need support DateTimeOffset. At the time of the client's browser contains a component of time offset, which can (and must) to be transmitted to the server when using DateTimeOffset. Thank you! :)