date-formatting

date_format() expects parameter 1 to be DateTime, string given

两盒软妹~` 提交于 2019-12-19 06:59:18
问题 I'm trying to replace my queries to PDO query and I have problems with date formats. I need to print dates in format d/m/Y H:i:s but after PDO script runs it prints the date in this format Y-m-d H:i:s while($row = $sql -> fetch(PDO::FETCH_ASSOC)) { ... echo "<td>" . date_format( $row['date'], 'd/m/Y H:i:s'). "";"</td>"; ... } Warning: date_format() expects parameter 1 to be DateTime, string given in But if I change the code to echo "<td>" . $row['date']. "";"</td>"; then it returns to Y-m-d H

date_format() expects parameter 1 to be DateTime, string given

不羁的心 提交于 2019-12-19 06:59:11
问题 I'm trying to replace my queries to PDO query and I have problems with date formats. I need to print dates in format d/m/Y H:i:s but after PDO script runs it prints the date in this format Y-m-d H:i:s while($row = $sql -> fetch(PDO::FETCH_ASSOC)) { ... echo "<td>" . date_format( $row['date'], 'd/m/Y H:i:s'). "";"</td>"; ... } Warning: date_format() expects parameter 1 to be DateTime, string given in But if I change the code to echo "<td>" . $row['date']. "";"</td>"; then it returns to Y-m-d H

How use a specific CultureInfo in Asp.net Web API

孤街醉人 提交于 2019-12-19 05:45:08
问题 I've recently added WEB API to an existing VS desktop application and everything worked fine, until yesterday when I had to add a GET method that took three parameters, one of them a Date. Well, at first I thought that that was going to be a piece of cake, but much to my surprise I noticed that when I sent 2014/07/09 (9th July) on the server where the application was installed it was treated like 2014/09/07 (7th September) and for that reason all my comparisons never worked. I have tried

Java program : need current Date in YYYY-MM-DD format without time in Date datatype [closed]

走远了吗. 提交于 2019-12-18 12:42:51
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 6 years ago . I need Date with only yyyy-mm-dd format, because DB2 table having 10 precision of date column. 回答1: Date date = new Date(); String modifiedDate= new SimpleDateFormat("yyyy-MM-dd").format(date); This will do. 来源:

Formatting date to human readable format

会有一股神秘感。 提交于 2019-12-18 12:11:20
问题 Lets say in my mysql database I have a timestamp 2013-09-30 01:16:06 and lets say this variable is $ts . How can I output this to show more like September 30th, 2013 ? 回答1: $timestamp = "2013-09-30 01:16:06"; echo date("F jS, Y", strtotime($timestamp)); //September 30th, 2013 Note the use of S to get the english ordinal suffix for the day. Since you're already using strtotime if you need a human readable data for the current time you can just use the keyword " now " as in strtotime("now")

Why does formatting a date return the wrong year?

你说的曾经没有我的故事 提交于 2019-12-18 09:12:29
问题 I want to print formatted dates on my page. I have an object date and I use $this->Time->format() for formatting. Everything works fine before December 27th. Unfortunately all dates after the December 26th, formatting change my year number. This is my debug($date) object(Cake\I18n\Time) { 'time' => '2015-12-30T00:00:00+0000', 'timezone' => 'UTC', 'fixedNowTime' => false } This is my debug($this->Time->format($date, 'YYYY')) '2016' I tried to use i18nFormat but I have the same problem. Here is

Convert dd/MM/yyyy to MM/dd/YYYY [duplicate]

*爱你&永不变心* 提交于 2019-12-18 04:08:12
问题 This question already has answers here : changing date format from dd/MM/yyyy to MM/dd/yyyy [duplicate] (4 answers) Closed 3 years ago . I need to convert "28/08/2012" to MM/dd/YYYY format that means "08/28/2012". How can I do that? I am using below code , but it threw exception to me. DateTime.ParseExact("28/08/2012", "ddMMyyyy", CultureInfo.InvariantCulture) 回答1: but it threw exception to me Problem: Your date contains / seperator ( "28/08/2012" ) and you are not giving that in your date

In what format is this date string?

北慕城南 提交于 2019-12-17 20:24:00
问题 Im trying to convert a bunch of NSStrings into NSDate objects. Here is an example string: 2013-04-25T15:51:30.427+1.00 But I can't figure out what format it is in, so far I have (The question marks are the bits I'm stumped with): yyyy-MM-ddTHH:mm:ss????zzz The main problem I'm having is with the '.427' part although if I'm making a mistake elsewhere, let me know :) Does anyone have any ideas? Or could point me to a list of all the possible date format specifiers? I found this: http://msdn

Using DateFormatter on a Unix timestamp

与世无争的帅哥 提交于 2019-12-17 15:48:10
问题 I get a crash when running and it points at the dateFormmater.timezone . The error in the console is: Could not cast value of type 'Swift.Optional' (0x1192bf4a8) to 'NSTimeZone' (0x1192c0270). the value of rowEvents.date is "1480134638.0" Im trying to pull out a Unix timestamp from Firebase saved as a string. Convert it to Date and again save it as a string so I can post it on a cell label. I got this code from StackOverflow. I plugged in my data and everything is all good until I run it. I

How do I specify date literal when writing SQL query from SQL Server that is linked to Oracle?

放肆的年华 提交于 2019-12-17 09:53:16
问题 I have a SQL Server 12.0 database that is linked to an Oracle 12.1 database. I want to create a view in the SQL Server database that returns data from an Oracle table filtered by date. The Oracle table has an index on the date column. A query that works successfully is: select * from ORADB..SCHEMA.MYTABLE where MYDATE >= '20140701'; However this runs very slowly. I assume it is because the comparison is taking place in SQL Server so every row is being returned. If I go: DECLARE @earliest date