Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • mikkel 143 posts 365 karma points
    Feb 24, 2019 @ 08:34
    mikkel
    0

    How do i change datetime to danish

    hi everyone How do i change datetime to danish i have try moment.js without luck

    i have also try this one here from stackoverflow and also without luck. So how do i do it ?

  • Casper 70 posts 308 karma points
    Feb 24, 2019 @ 09:57
    Casper
    0

    If you are looking for a way to convert moment() to Danish date time see this: https://momentjs.com/docs/#/i18n/

    If you are looking for a way to convert .NET DateTime to some Danish'ish format see this: https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings

    With moment() you need to set the locale like this: moment.locale('da')

    Given you have set you culture to Danish (in Umbraco), then [DateTime].ToString() C# should give you a Danish representation of a date. If it's not good enough then spice it up using a format string.

  • Tarik | WPPlumber 179 posts 801 karma points c-trib
    Feb 24, 2019 @ 21:44
    Tarik | WPPlumber
    0

    mikkel, have you tried to set that global by using the following code?

    <system.web>
        <globalization  culture="da-DK"  uiCulture="da-DK"/>
    </system.web>
    
  • Tarik | WPPlumber 179 posts 801 karma points c-trib
    Mar 11, 2019 @ 11:46
    Tarik | WPPlumber
    0

    mikkel, do you still have this issue?

  • mikkel 143 posts 365 karma points
    Mar 11, 2019 @ 19:58
    mikkel
    0

    Nope i have Solved the problem :)

  • Jan Borup Coyle 7 posts 32 karma points
    Mar 11, 2019 @ 20:19
    Jan Borup Coyle
    0

    How did you solved it ?

  • mikkel 143 posts 365 karma points
    Mar 11, 2019 @ 20:28
    mikkel
    0

    Hi jan i am on my phone so i Can find it tomorow and show it here 🙂

  • mikkel 143 posts 365 karma points
    Mar 12, 2019 @ 16:36
    mikkel
    0

    I use this using at the top of my page

    @using System.Globalization;
    

    and then i uotput whit this code here

    @item.CreateDate.ToString("dd. MMMM yyyy", new CultureInfo("da-dk"))
    

    You can see my entire code of the page if you want to se how i didt. I hope it helps :D

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.Begivenheder>
    @using ContentModels = Umbraco.Web.PublishedContentModels;
    @using System.Globalization;
    @{
        Layout = "master.cshtml";
        var selection = Model.Content.Site().FirstChild("begivenheder").Children().Where(x => x.IsVisible()).OrderBy("CreateDate desc");
    }
    <!-- Main Content -->
    @{
        int pageSize = 5; // How many items per page
        int page; // The page we are viewing
        /* Set up parameters */
        if (!int.TryParse(Request.QueryString["page"], out page))
        {
            page = 1;
        }
        /* This is your basic query to select the nodes you want */
        var nodes = Model.Content.Children.Where(x => x.DocumentTypeAlias == "nyBegivenhed").OrderBy("CreateDate desc");
        int totalNodes = nodes.Count();
        int totalPages = (int)Math.Ceiling((double)totalNodes / (double)pageSize);
        /* Bounds checking */
        if (page > totalPages)
        {
            page = totalPages;
        }
        else if (page < 1)
        {
            page = 1;
        }
        <div class="container">
            <div class="row">
                <div class="col-lg-8 col-md-10 mx-auto">
                    <h1 class="main-page-heading">@Umbraco.Field("navnNyBegivenhed")</h1>
                    @foreach (var item in nodes.Skip((page - 1) * pageSize).Take(pageSize))
                    {
                        <div class="post-preview">
                            <h2 class="post-title">@item.GetPropertyValue("navnNyBegivenhed")</h2><p class="post-meta">Skrevet af:&nbsp;@item.CreatorName &nbsp;d.&nbsp;@item.CreateDate.ToString("dd. MMMM yyyy", new CultureInfo("da-dk"))</p>
                            <p id="text-transform-teaser">@Umbraco.TruncateByWords(item.GetPropertyValue("beskrivelseBegivenhed").ToString(), 20)</p>
                            <a href="@item.Url" class="btn btn-danger btn-pagination">Se begivenhed</a>
                        </div>
                        <hr />
                    }
                    @{
                        if (totalPages > 1)
                        {
                            <div class="pagination-class">
                                <ul class="pagination">
                                    @if (page > 1)
                                    {
                                        <li><a style="margin-right: 10px;" class="btn btn-danger btn-pagination" href="?page=@(page-1)">Tilbage</a></li>
                                    }
                                    @*@for (int p = 1; p < totalPages + 1; p++)
                                        {
                                            <li style="margin-right: 10px;" class="@(p == page ? "active" : string.Empty) btn btn-danger btn-pagination">
                                                <a href="?page=@p">@p</a>
                                            </li>
                                        }*@
                                    @if (page < totalPages)
                                    {
                                        <li><a style="margin-right: 10px;" class="btn btn-danger btn-pagination" href="?page=@(page+1)">Næste</a></li>
                                    }
                                </ul>
                            </div>
                        }
                    }
                </div>
            </div>
        </div>
    }
    
  • Tarik | WPPlumber 179 posts 801 karma points c-trib
    Mar 12, 2019 @ 17:08
    Tarik | WPPlumber
    0

    mikkel, I saw many questions in the forum without selected solution if you want to make your question status obvious a bit select an answer.

Please Sign in or register to post replies

Write your reply to:

Draft