Convert a date format in PHP

Use strtotime() and date(): (See the strtotime and date documentation on the PHP site.) Note that this was a quick solution to the original question. For more extensive conversions, you should really be using the DateTime class to parse and format 🙂

Easy pretty printing of floats?

It’s an old question but I’d add something potentially useful: I know you wrote your example in raw Python lists, but if you decide to use numpy arrays instead (which would be perfectly legit in your example, because you seem to be dealing with arrays of numbers), there is (almost exactly) this command you said you made … Read more

What does {0} mean when found in a string in C#?

You are printing a formatted string. The {0} means to insert the first parameter following the format string; in this case the value associated with the key “rtf”. For String.Format, which is similar, if you had something like you’d create a string “This is a test. The value is 42“. You can also use expressions, and print … Read more

How to format numbers as currency strings

Intl.NumberFormat JavaScript has a number formatter (part of the Internationalization API). Use undefined in place of the first argument (‘en-US’ in the example) to use the system locale (the user locale in case the code is running in a browser). Further explanation of the locale code. Here’s a list of the currency codes. Intl.NumberFormat vs Number.prototype.toLocaleString A final note comparing … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)