iso8601

PHP - format date ISO8601?

怎甘沉沦 提交于 2019-12-04 07:59:08
I have a year (2002) and I'm trying to get it into the following format: 2002-00-00T00:00:00 I tried various iterations, the last of which was this: $testdate = DateTime::createFromFormat(DateTime::ISO8601, date("c")) echo date_format($testdate, '2002'); But, even if I come close, it always seems to add +00:00 to the end of it... The 'c' format in PHP always appends the timezone offset. You can't avoid that. But you can build the date yourself from components: date('Y-m-d\TH:i:s', $testdate); date('Y-m-d\TH:i:s\Z', time() - date('Z')); Best way is to use constants (PHP 5 >= 5.5.0, PHP 7) date

How to do formally correct parsing of ISO8601 date times in .Net?

爷,独闯天下 提交于 2019-12-04 07:42:41
There are many SO questions and answers regarding parsing of ISO8601 date/times in .NET and C#. However, there doesn't seem to be a 'definitive' answer anywhere, i.e. an answer that presents a formally correct ISO8601 parser that would correctly parse all of the possible format variants within ISO8601 and that would disallow non-ISO8601 variants. This SO answer is the closest match so far... How to create a .NET DateTime from ISO 8601 format Okay. Let's start with the limitations you are placing on ISO 8601 yourself: You want a DateTime, so all formats that only result in a time-of-day,

Parsing a date string using java.text.SimpleDateFormat

梦想与她 提交于 2019-12-04 06:10:03
问题 I have a weird problem, I need to parse a date string that looks like 1997-02-14T00:00:00.0000000+05:30 . The odd thing about the date string is the time zone information. It's +05:30 instead of the usual +0530 . I have the basic format string ready, yyyy-MM-dd'T'HH:mm:ss.SSSSSSSZ which would have worked like a charm, if not for the TZ information. Can anyone suggest a solution to this problem? Is there some kind format string which can handle that kind of TZ info? Thanks in advance. 回答1: Can

ISO-8601 in Postgres: How to insert only year in type date? (incomplete date-time values)

旧巷老猫 提交于 2019-12-04 05:05:36
问题 The Postgres database claims it supports the ISO-8601 standard. In ISO-8601 a date format "yyyy", i.e. consisting of only the year, is fine and acceptable. But I can't find a way to add only a year to a Postgres database field of the type "date". Any idea if I'm doing something wrong or is this feature missing in Postgres? I've seen other posts advising to set the date to "yyyy-01-01" but that is not what I want and need (since it marks a specific day of a month of a year). Scenario The

What is the value of the ISO 8601 duration `P1M` (in seconds)?

╄→尐↘猪︶ㄣ 提交于 2019-12-04 04:40:57
问题 Suppose I have an ISO 8601 duration, expressed as "P1M" . Phrased colloquially, this means "one month." Is there a standard rule for converting this into a number of seconds, assuming the start date is not known? For 30-day months, it might be 2,592,000. For 31-day months, it might be 2,678,400. In February, it might be 2,419,200 or it might be 2,505,600. My gut says there's no way to resolve "one month" to an exact number of seconds without knowing context, and where those seconds are laid

Date/Time Conversion ColdFusion

跟風遠走 提交于 2019-12-04 03:53:33
问题 I'm working with a script that displays the date and time in ISO 8601 format like so: 2012-05-17T17:35:44.000Z . but I would like it to display in the normal ColdFusion timestamp format when using the #Now()# notation ... so in this format: {ts '2012-05-17 17:35:44'} How can I do this? 回答1: As of CF 10, ISO-8601 is supported directly by parseDateTime. <cfset string = "1997-07-16T19:20:30+01:00"> <cfset date = parseDateTime(string, "yyyy-MM-dd'T'HH:mm:ssX")> Runnable Example on TryCF.com 回答2:

Representing Fraction of Second with ISO 8601:2004

血红的双手。 提交于 2019-12-03 16:01:06
The following is the definition of IS0 8601:2004 standard. It says that the fraction of second can be represented with one to six digits. Can I use all the 6 digits for representing the fraction of a second? Are the following Representation correct, if I use 6 digits for representing fraction of a second? 1ms -- 001000 10ms -- 010000 100ms -- 100000 {Extended Time Format} (32 bytes) YYYY-MM-DDThh:mm:ss.sTZD YYYY = Year 0000 to 9999 MM = Month 01 to 12 DD = Day 01 to 31 T = special separator T hh = Hour 00 to 23 mm = Minute 00 to 59 ss = Second 00 to 59 s = one to six digits representing a

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

Why does the ISO-8601 specification appear to be universally ignored when it comes to decimals? [closed]

余生颓废 提交于 2019-12-03 06:17:19
Closed . This question is opinion-based. It is not currently accepting answers. Learn more . Want to improve this question? Update the question so it can be answered with facts and citations by editing this post . From the ISO-8601:2004(E) Specification: 4.2.2.4 Representations with decimal fraction If necessary for a particular application a decimal fraction of hour, minute or second may be included. If a decimal fraction is included, lower order time elements (if any) shall be omitted and the decimal fraction shall be divided from the integer part by the decimal sign specified in ISO 31-0, i

How to get JSON.NET to serialize date/time to ISO 8601?

只愿长相守 提交于 2019-12-03 05:46:48
I have a Web API application that returns JSON to consumers who may not be using Microsoft technologies. When my controller returns an object with DateTime properties as JSON, it serializes the date in this format: 2017-03-15T00:00:00-04:00 This is giving the consumer a bit of a headache as they're expect it to be in ISO 8601 format. Some research has told me that JSON.NET now uses ISO 8601 by default (I am using 9.0.1). When I run this code... Clipboard.Copy(JsonConvert.SerializeObject(DateTime.Now)); ...I get this: 2017-03-15T09:10:13.8105498-04:00 Wikipedia shows these as valid ISO 8601