PHP 8.5.0 Alpha 4 available for testing

Voting

: min(four, eight)?
(Example: nine)

The Note You're Voting On

jthome at fcgov dot com
21 years ago
Had a similar problem as curlee, except I needed to create a JDE_ERP date. [format is CYYDDD]

<?php

function jde_date_create($month, $day, $year){
/*
* NOTE: $month and $day CANNOT have leading zeroes,
* $year must be'YYYY' format
*/
$jde_year_prefix = substr($year, 0, 1) - 1;
$jde_year_suffix = substr($year, -2);

//note that valid years for mktime are 1902-2037
$timestamp = mktime(0,0,0,$month, $day, $year);
$baseline_timestamp = mktime(0,0,0,1,0,$year);

$day_count = round(($timestamp - $baseline_timestamp)/86400);
$day_count_padded = str_pad($day_count,3,"0",STR_PAD_LEFT);

return (
$jde_year_prefix . $jde_year_suffix . $day_count_padded);

}

echo
jde_date_create(6,25,2000);// will return '103176'

?>

--
Jim

<< Back to user notes page

To Top