class Zend_Date not found - zend-framework

I googled a lot until now, but I couldn't find anything that works.
I need to save a proper datetime value in my mySQL database, so I tried as used in ZF1 this one:
$date = new Zend_Date();
echo $date->toString('YYYY-MM-dd HH:mm:ss');
I got the error class Zend_Date not found
Blockquote
What is it in ZF3, is it deprecated? If yes how is the name of the new class and how to get with composer. If not, what is wrong, what do I need as use statement.
Of course this one works
$heute = date("Y-m-d H:i:s");
But the question is furtherhin why can't I use Zend_Date?

When PHP 5.3 released, it has DateTime built in class. That's why Zend_Date was not used anymore. So, since ZF2 Zend_Date was not exist anymore.
So, just use DateTime built in class, and this doesn't need loaded in composer.
http://php.net/manual/en/class.datetime.php

Under this link you have all zf3 components:
https://docs.zendframework.com/
It looks like there is no longer Zend_Date in zend framework components.
P.s.
I recommend using Carbon (http://carbon.nesbot.com) or built-in php date functions. I prefer object-oriented style:
http://php.net/manual/en/class.datetime.php

Related

Get current time/date in purescript

This seems to me a weird question, but I have gone through the purescript-datetime and purescript-js-date and I just cannot find a way to get current DateTime. Is there some hidden library function or do I have to go through FFI?
You can use the now or nowDateTime functions from purescript-now.

Entity Framework Code First use SQL Server datetime2 instead of datetime everywhere

I know this can be accomplished using the Fluent API on a single property, but I want to have this automatically happen for everywhere I use a .NET DateTime in my model. Here's an example of doing a single property:
modelBuilder.Entity<T>()
.Property(f => f.MyDateTimeProperty)
.HasColumnType("datetime2");
But instead of only on this one property I want it to happen everywhere automatically. There is a fix for this in Model First by editing the T4 generation template so I know it can be done there but I need the same thing in Code First.
You want to use a Custom Code First Convention.
There's an example of exactly what you are trying to do here: http://msdn.microsoft.com/en-us/data/jj819164.aspx

Using Concat in TYPO3 Extbase Query

i am struggling a little challenge and i am wondering what the solution might be as I couldn't find an answer in the documentation.
Here is my current working query (part):
$constraints[] = $query->like('kategorie', '%'.$kategorie.'%');
What I want to do is something like:
$constraints[] = $query->like(CONCAT(',', kategorie, ','), '%,'.$kategorie.',%');
Which obviously doesn't work at all. : -)
Every Help is really appriciated. Hope someone know the right syntax. TYPO3 Version is latest 6.1
Thank's alot!
First of all, Extbase query generation didn't change in 6.0, so it's the same for 4.x and 6.x.
Maybe you misunderstand the way Extbase is builing the query.
$query->like('property', '%value%');
will return an object when %value% is contained in "property". Such a property must be defined in the domain model. You can only query properties that have a "getProperty" method in their domain model.
Looking at your code, I think you're finding a way to query for a value being present in a comma-separated value list? Then you would use
$query->in('kategorien', $kategorie);
EDIT:
Your specific problem seems to be that you are not using a true relation for assigning "Kategorien" to your entity. You're using a comma-separated list to hold references to another model. You're discouraged to do so, but it is technically possible and used in the TYPO3 core: The FrontendUser model has a property "usergroup" that works in the same way.
Please have a look at the FrontendUser model: https://git.typo3.org/Packages/TYPO3.CMS.git/blob/HEAD:/typo3/sysext/extbase/Classes/Domain/Model/FrontendUser.php
The annotation of your Kategorien must be correct, e.g.:
/**
* #var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\My\Extension\Domain\Model\Kategorien>
*/
protected $kategorien;
Also make sure that getKategorien is correct.
If you still have problems, keep in mind that the TCA definition must be working to have Extbase work correctly.
In my opinion, a best practise would be to use the category API introduced in TYPO3 6.0:
http://wiki.typo3.org/TYPO3_6.0#Category

FireBreath: how can I pass dates from my plugin to Java Script

I'm trying to create a simple FireBreath plugin. I need to pass a date from JavaScript to my plugin and to get date from my plugin and use it in JavaScript.
I have an idea about getting date in FB plugin from JS. I can use a FB::JSObjectPtr parameter and get it's attributes with GetAttribute.
The main question is how to pass a date back to JS? The only way I can find in my head is to create class DateJSAPI derived from FB::JSAPIAuto an implement all methods so JS can use instance of my class as JS Date.
I don't like such a weird way.
Can anyone advise me some good way of returning date to JS?
I spent several hours once trying to find a way to create Date objects in a NPAPI plugin (specifically in FireBreath) and it seems the only way to do so is to create a javascript function that returns a date object. Given that you'd have to pass a string or timestamp into said function it seems silly to do this.
If I were you I'd just send it as a timestamp (number) so you can convert it to a Date object once it gets to javascript.

Do I need to provide an IFormatProvider when converting a date to a string with a specific format?

If I'm using this:
DateTime.Now.Date.ToString("yyyy-MM-dd")
FXCop complains that I'm violating CA1305 and says that I should provider an IFormatProvider. Do I need to? I'm asking for the date in a specific format anyway (which is the format I'm expected to put it into the XML as).
Would providing a format provider make any difference? Might it actually produce the wrong results in this case?
Why don't you want to specify the format provider?
If it is just laziness then I can recommend defining two snippets. ic for CultureInfo.InvariantCulture and cc for CultureInfo.CurrentCulture.
Never assume anything about how conversion to string works with the default culture. Not everyone in the world uses the gregorian calendar. Some day you customer might hire a contractor with a computer with another calendar as default and then you are not generating correct XML. Explain then to your customer that you didn't want to follow the FxCop recommendation.
Best thing would be if .Net included a Xml Culture. Then you could just do
DateTime.Today.ToString("d", CultureInfo.Xml)
For some reason Microsoft choose to create a separate class instead XmlConvert. The class has been there since .Net 1.0.
XmlConvert.ToString(DateTime.Today, "yyyy-MM-dd")
will always create a correct Xml date.
Not sure if it is bug or intended behaviour but XmlConvert.ToString(DateTime.Today, "d") will not create a valid Xml date.
so after a bit more research it seems that in my instance it doesn't make any difference, but in the general case months might be displayed in a specific locale.
More details here:
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx