Posts

Showing posts with the label datetime

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

Convert java Calendar object from local time to UTC

Convert java Calendar object from local time to UTC How do I convert a Java Calendar object from local time to UTC? This what I have tried: Calendar Calendar calendar = Calendar.getInstance(); calendar.setTimeZone(TimeZone.getTimeZone("UTC")); calendar.setTime(localDateTime.getTime()); SimpleDateFormat outputFmt = new SimpleDateFormat("MMM dd, yyy h:mm a zz"); String dateAsString = outputFmt.format(calendar.getTime()); System.out.println(dateAsString) Time is always displayed in MT not GMT. I want to store the calendar in UTC in a database (I'm not concerned with formatting or displaying the time). Possible duplicate of Convert Local time to UTC and vice versa – Shubhendu Pramanik Jun 30 at 12:48 3 Answers 3 ...