Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

256
Views
Custom format Korean date with forward-slash not working

If you run the following code: https://dotnetfiddle.net/kBqe9x

using System;
                    
public class Program
{
    public static void Main()
    {
        var date = DateTime.Now;
        Console.WriteLine(date.ToString("yyyy/MM/dd", System.Globalization.CultureInfo.GetCultureInfo("ko-KR")));
    }
}

The result will be 2022-01-18.

Why is .net replacing the forward-slash with a dash?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

The forward slash is a special character, in DateTime you have to write that like '/'

using System;
                    
public class Program
{
    public static void Main()
    {
        var date = DateTime.Now;
        Console.WriteLine(date.ToString("yyyy'/'MM'/'dd", System.Globalization.CultureInfo.GetCultureInfo("ko-KR")));
    }
}
over 4 years ago · Santiago Trujillo Report

0

That's because ko-KR culture info has such a date pattern for a short date. If you take a look at the ShortDatePattern property of the CultureInfo you've created here, you'll see the following.

var cultureInfo = System.Globalization.CultureInfo.GetCultureInfo("ko-KR");
Console.WriteLine(cultureInfo.DateTimeFormat.ShortDatePattern);

This prints out: yyyy-MM-dd

Fiddle: https://dotnetfiddle.net/CRxKtQ

If you want to keep the pattern you specified in ToString method, simply remove the culture info.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!