Jump to content

$datetime->convertDateFormat() does not produce the correct format

Eunico Cornelius

Recommended Posts

I am trying to get the strftime format from the function convertDateFormat(). However, the output has $ signs in it which i cannot use in strftime.(example of conversion : $d/$m/%Y what strftime actually uses: %d/%m/%Y). Am I in the wrong here or is there some way to format strftime? Thank you in advance :).

  • Like 1
Link to comment
Share on other sites

4 minutes ago, alxndre said:

What exact code are you running so we'd have an idea where the $ is coming from? I just tested right now:

echo $datetime->convertDateFormat("Y-M-D","strftime");

// output


I'm sorry I forgot to mention that what I used as the first parameter is from the array 

$formats = $datetime->getDateFormats();

which when implemented, will look like this

$dateformat = $datetime->convertDateFormat($formats[4], 'strftime');

why is it not doable to get the format from the list?

Link to comment
Share on other sites

I dunno why yet, but can confirm the weird behavior. The function works when fed with strings but gives weird results when input is taken from the array.

// output looping through getDateFormats()
l, j F Y : %A, $-d %B %Y
j F Y : $-d %B %Y
d-M-Y : $d-%b-%Y
dMy : $d%b%y
d/m/Y : $d/$m/%Y
d.m.Y : $d.$m.%Y
d/m/y : $d/$m/%y
d.m.y : $d.$m.%y
j/n/Y : $-d/$-m/%Y
j.n.Y : $-d.$-m.%Y
j/n/y : $-d/$-m/%y
j.n.y : $-d.$-m.%y
Y-m-d : %Y-$m-$d
Y/m/d : %Y/$m/$d
Y.n.j : %Y.$-m.$-d
Y/n/j : %Y/$-m/$-d
Y F j : %Y %B $-d
Y-M-j, l : %Y-%b-$-d, %A
Y-M-j : %Y-%b-$-d
YMj : %Y%b$-d
l, F j, Y : %A, %B $-d, %Y
F j, Y : %B $-d, %Y
M j, Y : %b $-d, %Y
m/d/Y : $m/$d/%Y
m.d.Y : $m.$d.%Y
m/d/y : $m/$d/%y
m.d.y : $m.$d.%y
n/j/Y : $-m/$-d/%Y
n.j.Y : $-m.$-d.%Y
n/j/y : $-m/$-d/%y
n.j.y : $-m.$-d.%y

Will investigate more.


Edit :


The code actually has those $ symbols. Submitted as an issue.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...