PHP Julian date function

Viewed 48

So i have this function that converts date to julian date. It works as excpected, but the result it returns is the timestamp of today in julian date - today 12/08/2022 = 122223

function data_giuliana()
{
 $anno = Carbon::now()->format('y'); // 2 digit year

 $timestamp = Carbon::now()->firstOfYear()->timestamp;
 $yearFirstDay = floor($timestamp / 86400);
 $today = ceil(Carbon::now()->timestamp / 86400);
 $giorno = ($today - $yearFirstDay);

 $data_giuliana = "1" . $anno . $giorno;

 return $data_giuliana;
}

I'm trying to edit it so that it recieves the param of a date and converts it

What i'm trying is something like this:

function data_giuliana($date) {
  // conversion logic of $date
  // return $converted date
}

Let's say i would like to convert to a julian date 1997/07/07 how should be the function logic? in julian date should be 097188.

1 Answers
Related