change the format of date c#

PHP
const currentTimeInSeconds=Math.floor(Date.now()/1000); //unix timestamp in secondsString pattern = "EEEEE dd MMMMM yyyy HH:mm:ss.SSSZ";
SimpleDateFormat simpleDateFormat =
        new SimpleDateFormat(pattern, new Locale("da", "DK"));

String date = simpleDateFormat.format(new Date());
System.out.println(date);
// 1. create a date instance
$date = new DateTime;

// 2. set the date using the setDate(year, month, date) method on the
//    $date instance
$date->setDate(1999,02,19);To convert the date-time format PHP provides strtotime() and date() function. We change the date format from one format to another.

Change YYYY-MM-DD to DD-MM-YYYY
<? php.
$currDate = "2020-04-18";
$changeDate = date("d-m-Y", strtotime($currDate));
echo "Changed date format is: ". $changeDate. " (MM-DD-YYYY)";
?>
Source

Also in PHP: