Copied to clipboard

Flag this post as spam?

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


  • Robert 63 posts 282 karma points
    Aug 20, 2014 @ 13:37
    Robert
    0

    Date time in Dutch format

    Hi,

    Does anyone know how i can get an Dutch Date time format like: Woensdag 20 Augustus 2014?

    Thank you!

    Kind regards, Robert

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Aug 20, 2014 @ 13:52
    Jeavon Leopold
    0

    Something like this:

    @DateTime.Now.ToString("F", CultureInfo.CreateSpecificCulture("nl-nl"))
    
  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Aug 20, 2014 @ 13:53
    Jeavon Leopold
    0

    Actually I think you want "D"

    @DateTime.Now.ToString("D", CultureInfo.CreateSpecificCulture("nl-nl"))
    
  • Robert 63 posts 282 karma points
    Aug 20, 2014 @ 13:55
    Robert
    0

    Thanks for your reply!

    How can i use the CultureInfo because i get an compiler error...

    Compiler Error Message: CS0103: The name 'CultureInfo' does not exist in the current context
    
  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Aug 20, 2014 @ 13:57
    Jeavon Leopold
    100

    Ah sorry, you need to add at the top of your script

    @using System.Globalization
    
  • Robert 63 posts 282 karma points
    Aug 20, 2014 @ 13:58
    Robert
    0

    Damn you're good!

    Works like the way i needed :)

    Thank you!

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Aug 20, 2014 @ 14:03
    Jeavon Leopold
    1

    Lol, you're very welcome!

  • Robert 63 posts 282 karma points
    Aug 20, 2014 @ 14:17
    Robert
    0

    Just one other question :)

    How can i get the publish date from the news-item instead of the Now date?

    What i had: Where dateTime is the publish date.

    @String.Format("{0:dd-MM-yyyy}", dateTime)
    

    I need it now in the line you've gaven me :)

     @DateTime.Now.ToString("F", CultureInfo.CreateSpecificCulture("nl-nl"))
    

    Thank you.

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Aug 20, 2014 @ 15:07
    Jeavon Leopold
    1

    I think just:

    @dateTime.ToString("D", CultureInfo.CreateSpecificCulture("nl-nl"))
    
  • Robert 63 posts 282 karma points
    Aug 20, 2014 @ 15:10
    Robert
    0

    Yes! Many thanks again!

    Now i'm done asking ;)

    Thank you

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Aug 20, 2014 @ 15:11
    Jeavon Leopold
    0

    np

  • Mike Chambers 635 posts 1252 karma points c-trib
    Aug 21, 2014 @ 09:07
    Mike Chambers
    0

    Would you not be better setting the site wide locale? Rather than add hoc string format manipulation?

  • Robert 63 posts 282 karma points
    Aug 21, 2014 @ 09:09
    Robert
    0

    How do you mean that?

  • Mike Chambers 635 posts 1252 karma points c-trib
    Aug 21, 2014 @ 14:00
    Mike Chambers
    0

    you can set in the web.config I think

    <globalization requestEncoding="UTF-8" responseEncoding="UTF-8" culture="auto" uiCulture="auto" /> for application wide

    or you can use the manage hostnames feature (right click your root node in the content tree) and use a dummy url (u7 might not even need a dummy url) and set the language.Really for multilanguage sites.. but think should aslo set the locale to do dates etc.. I have found it to be hit and miss in the past with core overriding, but this might have changed.

    (You'll need to add your language to the available languages in settings language.)

     

Please Sign in or register to post replies

Write your reply to:

Draft