Получите дату в нужном формате на разных языках программирования

Чтобы получить дату в определенном формате, вы можете использовать различные языки программирования и библиотеки. Вот несколько примеров:

  1. JavaScript:

    const currentDate = new Date();
    const formattedDate = currentDate.toLocaleDateString('en-US');
    console.log(formattedDate);

    Вывод: «14.12.2023» (на текущую дату)

  2. Python:

    import datetime
    current_date = datetime.datetime.now()
    formatted_date = current_date.strftime('%m/%d/%Y')
    print(formatted_date)

    Вывод: «14.12.2023» (на текущую дату)

  3. Java:

    import java.time.LocalDate;
    import java.time.format.DateTimeFormatter;
    
    LocalDate currentDate = LocalDate.now();
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
    String formattedDate = currentDate.format(formatter);
    System.out.println(formattedDate);

    Вывод: «14.12.2023» (на текущую дату)

  4. PHP:

    $currentDate = date('m/d/Y');
    echo $currentDate;

    Вывод: «14.12.2023» (на текущую дату)

  5. C#:

    using System;
    DateTime currentDate = DateTime.Now;
    string formattedDate = currentDate.ToString("MM/dd/yyyy");
    Console.WriteLine(formattedDate);

    Вывод: «14.12.2023» (на текущую дату)