Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

[UWP] How to change the format of a Toast Notification timestamp? Is it possible?

How to modify/change the format of the timestamp displayed on a toast notification? Or is it even possible? Because, I think it is dependent on the system's time format settings. Maybe I am wrong?

Want to change formats of the highlighted time stamp:

Answers

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    Do you want to custom it like this thread? https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/custom-timestamps-on-toasts

    If so, to use a custom timestamp, simply assign the DisplayTimestamp property on your ToastContent.

    ToastContent toastContent = new ToastContent()
    {
        DisplayTimestamp = new DateTime(2017, 04, 15, 19, 45, 00, DateTimeKind.Utc),
        ...
    };
    
  • Goutham_HasProblemsGoutham_HasProblems Member ✭✭✭
    edited September 16

    No no, this lets me change the time stamp. What I want to change is the time format. Because, after testing on various systems the observation was that the format varies from system to system. Example:
    On system 1, the time stamp is displayed as 12:45 PM, and on another system it is simply displayed as 12:45 p. There were cases where instead of time, the date got displayed like: 9/16 .
    All the 3 scenarios mentioned above are of a push notification sent to the systems at the same time.
    I am trying to understand what is affecting this format? or rather, what decides the format?

    The date format setting for the system which displayed 12:45 p is:

    How did it not display 12:45 PM or 12:45:00 PM ?

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    Do you want to change the time stamp for all of the notifications in notifications flyout items?

    On system 1, the time stamp is displayed as 12:45 PM, and on another system it is simply displayed as 12:45 p. There were cases where instead of time, the date got displayed like: 9/16 .

    Are these operations system have same version? Based on your description, this issue is related to the windows 10 settings, not related to the Xamarin development.

  • Do you want to change the time stamp for all of the notifications in notifications flyout items?

    If by 'time stamp', you mean the time displayed, then no. I don't want to modify the time. I just want to change the format.

    Are these operations system have same version? Based on your description, this issue is related to the windows 10 settings, not related to the Xamarin development.

    No, they are of different versions. It is not a Xamarin issue as UWP toast notification depends on the XML payload. Which is why even I am seeking clarification if it is due to the Windows setting or if there is a separate attribute in the XML schema. I haven't found any like that here: https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/toast-schema or here: https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/toast-xml-schema

Sign In or Register to comment.