Posts

Showing posts with the label date

DateFormatter transforms am/pm to a. m./p. m. in spanish

DateFormatter transforms am/pm to a. m./p. m. in spanish I am parsing with DateFormatter "Thu Jun 28 14:25:00 GMT+03:00 2018", and it correctly outputs Jun 28, 2018 2:25:00 pm. However when the user switches to Spanish locale the formatter outputs jun. 28, 2018 2:25:00 p. m. Is this normal? here is how I'm parsing the date DateFormatter dateFormatter = new DateFormatter(); dateFormatter.setDateFormatPattern("MMM dd, yyyy hh:mm:ss a"); mCalendar = new GregorianCalendar(mTimeZone); mCalendar.setTime(date); mSimpleDateFormat.applyPattern(pattern); mSimpleDateFormat.setTimeZone(mTimeZone); mSimpleDateFormat.format(mCalendar.getTime()); Apparently this is normal, I just googled for Spanish representation of AM/PM and found a bunch of articles about this. I think this is expected.. Interesting, indeed :) – Gennadii Saprykin Jun 29 at 8:21 ...

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...

Angular 5 Error with dates [on hold]

Angular 5 Error with dates [on hold] After having been puzzled for a while for the reason my dates were messed up, I made this simple test: var dt: Date = new Date(2008, 6, 30); console.log("test: " + dt); the result of the console was: test: Wed Jul 30 2008 00:00:00 GMT+0200 (ora legale Europa occidentale) which is exactly one month more than expected. Can anyone replicate? Do months start with 0 in Angular? This question appears to be off-topic. The users who voted to close gave these specific reasons: The Date class has nothing to do with Angular. And yes, its months start at 0. Why not read the documentation? developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… It clearly says: Note: The argument monthIndex is 0-based. This means that January = 0 and December = 11. – JB Nizet Jun 30 at 14:14 ...