How do I print curly-brace characters in a string while using .format?

You need to double the {{ and }}: >>> x = ” {{ Hello }} {0} ” >>> print(x.format(42)) ‘ { Hello } 42 ‘ Here’s the relevant part of the Python documentation for format string syntax: Format strings contain “replacement fields” surrounded by curly braces {}. Anything that is not contained in braces is … Read more

Convert one date format into another in PHP

The second parameter to date() needs to be a proper timestamp (seconds since January 1, 1970). You are passing a string, which date() can’t recognize. You can use strtotime() to convert a date string into a timestamp. However, even strtotime() doesn’t recognize the y-m-d-h-i-s format. PHP 5.3 and up Use DateTime::createFromFormat. It allows you to … Read more