Posts

Showing posts with the label format

Convert one date format into another in PHP

Convert one date format into another in PHP Is there a simple way to convert one date format into another date format in PHP? I have this: $old_date = date('y-m-d-h-i-s'); // works $middle = strtotime($old_date); // returns bool(false) $new_date = date('Y-m-d H:i:s', $middle); // returns 1970-01-01 00:00:00 But I'd of course like it to return a current date rather than the crack 'o dawn. What am I doing wrong? tech-blog.maddyzone.com/php/type-date-convert-php very nice article – Rituraj ratan Sep 27 '14 at 7:17 14 Answers 14 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. date() You can use strto...

printf() formatting for hex uint32_t without missing zeros. (in c89)

printf() formatting for hex uint32_t without missing zeros. (in c89) Wanted to print uint32 hex. Tried "PRIx32", looked bad to me: 967407c0 23 4481d55f ffffff52 de3cd140 2fc aa7363cf fffff40d 563270c0 2b86 So... tried this. Dirty but worked: /******************************************************************************* Print a digit in hex. *******************************************************************************/ void mpal_digit_t_print_hex( mpal_digit_t * input) { uint8_t p_1, p_2, p_3, p_4, p_5, p_6, p_7, p_8; p_1 = (uint8_t)(((*input) << 0) >> 28); p_2 = (uint8_t)(((*input) << 4) >> 28); p_3 = (uint8_t)(((*input) << 8) >> 28); p_4 = (uint8_t)(((*input) << 12) >> 28); p_5 = (uint8_t)(((*input) << 16) >> 28); p_6 = (uint8_t)(((*input) << 20) >> 28); p_7 = (uint8_t)(((*input) << 24) >> 28); p_8 = (uint8_t)(((*input) << 28) ...