Forum
Calc Builder Support
Calc Builder supportForums
Public write access is disabled. Please login
Re: Add day 31.03.2017 13:49
Hello,
you can try to use php datetime class in order to perform your function, the code should look like:
$dayf=40;
//create date object from format
$newDate = DateTime::createFromFormat('m/d/y', $baslangic);
//add interval
$newDate->modify('+'.$dayf.' days');
//return formatted new date
$result=$newDate->format('m/d/y');
That should do the work, format to be used here is 'm/d/y' if you use 2 digits for year, or,
'm/d/Y'
in case you use the 4 digits format.
Hope this helps, regards
Moonsoft Team
www.moonsoft.es
you can try to use php datetime class in order to perform your function, the code should look like:
$dayf=40;
//create date object from format
$newDate = DateTime::createFromFormat('m/d/y', $baslangic);
//add interval
$newDate->modify('+'.$dayf.' days');
//return formatted new date
$result=$newDate->format('m/d/y');
That should do the work, format to be used here is 'm/d/y' if you use 2 digits for year, or,
'm/d/Y'
in case you use the 4 digits format.
Hope this helps, regards
Moonsoft Team
www.moonsoft.es
Re: Add day 31.03.2017 14:24
Thanks support.
Code produces incorrect results.
Sample baslangic is 01/01/2017
Result: 10/02/2017 This is correct
Sample baslangic is 30/01/2017
Result: 11/07/2019 This is not correct.
I can tired code:
$dayf=40;
//create date object from format
$newDate = DateTime::createFromFormat('m/d/Y', $baslangic);
//add interval
$newDate->modify('+'.$dayf.' days');
//return formatted new date
$result=$newDate->format('m/d/Y');
Code produces incorrect results.
Sample baslangic is 01/01/2017
Result: 10/02/2017 This is correct
Sample baslangic is 30/01/2017
Result: 11/07/2019 This is not correct.
I can tired code:
$dayf=40;
//create date object from format
$newDate = DateTime::createFromFormat('m/d/Y', $baslangic);
//add interval
$newDate->modify('+'.$dayf.' days');
//return formatted new date
$result=$newDate->format('m/d/Y');
Re: Add day 31.03.2017 16:37
Hi,
are you sure the date format is the right one? You said you're using mm/dd/yy format, but from your example:
30/01/2017
seems you're using dd/mm/yy instead? If so, you only need to correct the date format to
d/m/Y
at the 2 date functions (createfromformat and format) in order to get the right results. If the format is not the exact one you'll be getting weird unexpected results when adding the days.
Regards
Moonsoft Team
www.moonsoft.es
are you sure the date format is the right one? You said you're using mm/dd/yy format, but from your example:
30/01/2017
seems you're using dd/mm/yy instead? If so, you only need to correct the date format to
d/m/Y
at the 2 date functions (createfromformat and format) in order to get the right results. If the format is not the exact one you'll be getting weird unexpected results when adding the days.
Regards
Moonsoft Team
www.moonsoft.es