Page 1 of 1

How to create a string using date, number and string?

Posted: Mon Sep 09, 2019 12:10 pm
by Quincyhazz

I am trying to create a string variable that has the following format - $var = date_format($rsnew["DATE_FLD"],"Ymd") . $numbervar . $stringvar but $var only stores $numbervar . $stringvar. for example, I wish to output $var = 20190621001a2b12f instead I get $var=001a2b12f. Your assistance is be greatly appreciated. The date portion is missing.


Re: How to create a string using date, number and string?

Posted: Mon Sep 09, 2019 1:46 pm
by Webmaster

$rsnew["DATE_FLD"] is string, not date, you need to convert it to date first, see example in https://www.php.net/manual/en/datetime.format.php.


Re: How to create a string using date, number and string?

Posted: Tue Sep 10, 2019 12:04 am
by Quincyhazz

$var = date_format(date_create($rsnew["DATE_FLD"]),"Ymd") solved the problem. Thank you for pointing me int right direction.