date-format

How do I store an UTC ISO8601 date in a MySQL database?

丶灬走出姿态 提交于 2019-12-03 14:56:42
问题 I have thousands of dates in the following format: 2011-10-02T23:25:42Z (aka ISO 8601 in UTC) What MySQL data type should I use for storing such a ISO8601 date in a MySQL database? E.g. Datetime , timestamp or something else? Which is best for comparison (eg. getting records between two dates/times) and ordering the results from queries? What about if the database is very large? And what would be the best way to convert the above PHP string for MySQL storage? (I'm guessing date_default

Excel 2010 - change US dates to UK format

ⅰ亾dé卋堺 提交于 2019-12-03 13:36:40
I have imported a CSV file with 2 long columns of dates. These dates are in the US format Aug/28/2013 and I want them to be in the standard UK dd/mm/yyyy format. I have tried formatting the cells as US dates and then converting them to number-only formats, and various other permutations within the Date format box, but with no success. Can anyone rid me of these awful US dates please? Another solution without using a formula: Select the relevant columns Choose Data → Text to Columns… Select “Delimited” and click Next Untick all delimiters and click Next Select data column format “Date: MDY” and

PHP date format, remove time and more [duplicate]

孤人 提交于 2019-12-03 10:49:10
This question already has answers here : Convert one date format into another in PHP (15 answers) Possible Duplicate: Convert one date format into another in PHP Starting from: $date = '2012-09-09 03:09:00' I would like to do two things. Remove the time from the string, so it will become "2012-09-09" . Calculate how many years, days, and hours have passed since this date using the server current date/time/timezone. Could anyone help me figure this out? Use DateTime : $date = '2012-09-09 03:09:00'; $createDate = new DateTime($date); $strip = $createDate->format('Y-m-d'); var_dump($strip); //

Google Sitemap Date Format

你。 提交于 2019-12-03 09:59:49
I need date format for sitemaps in php. How can i do that ? Is this output right ? <lastmod>2012-08-02EEST18:01:18+03:00</lastmod> If you have the timestamp you can format the date correctly like this: <lastmod><?php echo date('c', $timestamp); ?></lastmod> Time stamp could be time() (for current time) or some other method of fetching a unix tiemstamp like strtotime() To format the current timestamp in W3C Datetime encoding (as used in sitemap.xml files) use the following parameters. echo date('Y-m-dTH:i:sP', time()); As of PHP5 you can also use the c format character to print the exact same

iOS - Friendly NSDate format

痴心易碎 提交于 2019-12-03 09:41:05
问题 I need to display the date of posts in my app to the user, right now I do it in this format: "Fri, 25 May". How would I format an NSDate to read something like "2 hours ago"? To make it more user friendly. 回答1: NSDateFormatter can't do things like that; you're going to need to establish your own rules. I guess something like: - (NSString *)formattedDate:(NSDate *)date { NSTimeInterval timeSinceDate = [[NSDate date] timeIntervalSinceDate:date]; // print up to 24 hours as a relative offset if

issue with date formatting using NSDateFormatter

痴心易碎 提交于 2019-12-03 08:45:26
I have a date string which I want to convert to another format. The original date string example is : "2013-06-04 02:19:21 +0000" I want to convert this to "Wed, Jun 4" NSString * date_string = @"2013-06-04 02:19:21 +0000"; NSDateFormatter *complexdateFormater = [[NSDateFormatter alloc] init]; [complexdateFormater setDateFormat:@"yyyy-M-DD HH:mm:ss Z"]; NSDate* complexdate = [complexdateFormater dateFromString:date_string]; NSString *formatString = [NSDateFormatter dateFormatFromTemplate:@"EE, MMM d" options:0 locale:[NSLocale currentLocale]]; NSDateFormatter *dateFormatter = [[NSDateFormatter

Convert data from email header

蹲街弑〆低调 提交于 2019-12-03 07:19:02
Does anyone could help me how to convert data from email header? I have the next date format from email header: Wed, 28 Apr 2010 21:59:49 -0400 I need to convert them into mysql Date, or timestamp. Thanks! You should be using DateTime for this, specifically DateTime::createFromFormat() : $str = 'Wed, 28 Apr 2010 21:59:49 -0400'; $date = DateTime::createFromFormat( 'D, d M Y H:i:s O', $str); Now, you have a Date object in $date , and you can grab the unix timestamp (if that's what you want), or you can format it into a date for MySQL. echo $date->getTimestamp(); // Outputs: 1272506389 echo

DB2 Date format

本小妞迷上赌 提交于 2019-12-03 05:33:52
I just want to format current date into yyyymmdd in DB2. I see the date formats available, but how can I use them? http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.db2z10.doc.intro%2Fsrc%2Ftpc%2Fdb2z_datetimetimestamp.htm SELECT CURDATE() FROM SYSIBM.SYSDUMMY1; I dont see any straightforward way to use the above listed formats. Any suggestion? SELECT VARCHAR_FORMAT(CURRENT TIMESTAMP, 'YYYYMMDD') FROM SYSIBM.SYSDUMMY1 Should work on both Mainframe and Linux/Unix/Windows DB2. Info Center entry for VARCHAR_FORMAT() . One more solution REPLACE (CHAR(current date,

How to add weeks to date using javascript?

筅森魡賤 提交于 2019-12-03 05:29:16
Javascript definitely isn't my strongest point. I've been attempting this for a couple of hours now and seem to be getting stuck with date formatting somewhere. I have a form where a user selected a date (dd/mm/yyyy) and then this date will be taken and 2 weeks will be added to it and then date will be copied to another form field. My latest attempt below isn't even adding a date yet just copying the selected date in one form field to another, if I select '03/02/2012', it outputs 'Fri Mar 02 2012 00:00:00 GMT+0000 (GMT Standard Time)', so its outputting in American format as well as the full

How do I store an UTC ISO8601 date in a MySQL database?

烈酒焚心 提交于 2019-12-03 04:38:16
I have thousands of dates in the following format: 2011-10-02T23:25:42Z (aka ISO 8601 in UTC) What MySQL data type should I use for storing such a ISO8601 date in a MySQL database? E.g. Datetime , timestamp or something else? Which is best for comparison (eg. getting records between two dates/times) and ordering the results from queries? What about if the database is very large? And what would be the best way to convert the above PHP string for MySQL storage? (I'm guessing date_default_timezone_set('UTC'); would be used?) I think that keeping your date-time values in field of type DATETIME