Convert UTC to AEST / AEDT whichever is suitable.

1 Answer 51 Views
General Discussions Grid
Shubham
Top achievements
Rank 1
Iron
Shubham asked on 09 Mar 2022, 05:41 AM | edited on 09 Mar 2022, 05:46 PM

Hi,

I have a kendo datagrid which fetches data from backend and has a date column (which is stored in the backend as UTC) .
Now I am displaying date like this in my frontend(this is one of the column in my Kendo Grid):


                    {
                        field: "createdDate",
                        title: "Created Date",
                        template:"<div class='createdDateTemplate'>#= kendo.toString(kendo.parseDate(createdDate), 'dd/MM/yyyy hh:mm tt') #</div>",
                        width: 150
                    }

We need to display the time according to AEST or AEDT whichever is being followed . Can I do that from the template itself?

I know that Kendo automaticaaly renders date time in local format something like this for me:

GMT+1000 (Australian Eastern Standard Time)


But is it possible to display this time with +10 added to time itself ?

1 Answer, 1 is accepted

Sort by
0
Georgi Denchev
Telerik team
answered on 11 Mar 2022, 02:56 PM

Hi, Shubham,

Yes, you can use the kendo.timezone.convert method directly inside the template.

template:"<div class='createdDateTemplate'>#= kendo.toString(kendo.timezone.convert(kendo.parseDate(createdDate), 'Etc/UTC', 'Etc/GMT+10'), 'dd/MM/yyyy hh:mm tt') #</div>",

Dojo:

https://dojo.telerik.com/@gdenchev/AbaxELIG 

You can also use the kendo.timezone.apply method to apply an offset:

// 10h = 600 minutes, offset the time by 600.
template:"<div class='createdDateTemplate'>#= kendo.toString(kendo.timezone.apply(kendo.parseDate(createdDate), 600), 'dd/MM/yyyy hh:mm tt') #</div>",

Dojo:

https://dojo.telerik.com/@gdenchev/ajADOker 

And here you can find  the available timezone abbreviations:

https://runner.telerik.io/fullscreen/unOWiyIG 

Best Regards,
Georgi Denchev
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.

Tags
General Discussions Grid
Asked by
Shubham
Top achievements
Rank 1
Iron
Answers by
Georgi Denchev
Telerik team
Share this question
or