How to change datetime in Vue? - laravel

Trying to use Vue for the first time.
I dont know how to change the datetime in Vue.
I know it works in laravel, like this:
{{ date("d.m.Y", strtotime($file->created_at)) }}
How can I change datetime in Vue?
This is what I tried in Vue:
<time datetime="1.1.2019">#{{ file.created_at }}</time>
and it shows me the exact database entry on the view page:
2019-01-25 12:03:40
But I want it to appear like this:
25.02.2019 12:03. 40
Thank you!

Create a Vue method -
formattedDate:function(d){
let arr = d.split(/[- :]/);
let date = new Date(Date.UTC(arr[0], arr[1]-1, arr[2], arr[3], arr[4], arr[5]));
return date.getDate() + "." + (date.getMonth() + 1) + "." + date.getFullYear() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds()
}
And then Call that method within double curly brackets
<time datetime="1.1.2019">#{{ formattedDate(file.created_at) }}</time>

Related

cypress use value outside .then() block

i have a case where i enter a searchTerm to a search field. Then I want to count the results shown to randomly select one of the entries. But I cannot realize it with cypress
let countOfElements = "";
cy.get(this.SEARCH_RESULT + ' > a').then($elements => {
countOfElements = $elements.length;
cy.log(countOfElements)
cy.log("Found " + countOfElements + " results for search term + " + searchTerm)
});
cy.get(this.SEARCH_RESULT + ' > a').invoke('val').as('searchEntries')
//This is obviosly not working, but I don't get how to fix this.
let randomNumber = this.getRandomNumberBetweenTwoValues(0, cy.get('#searchEntries')));
cy.get(this.SEARCH_RESULT + ' > a').eq(randomNumber).click()
I tried different things, like storing the value with .as() but I never seem to have access to the value outside a .then() block. So how I can use the value in my "getRandomNumber..." function to decide with entry in the result list shall be selected?
Pls help. thx
let countOfElements = "";
cy.get(this.SEARCH_RESULT + ' > a').then($elements => {
countOfElements = $elements.length;
cy.log(countOfElements)
cy.log("Found " + countOfElements + " results for search term + " + searchTerm)
});
cy.get(this.SEARCH_RESULT + ' > a').invoke('val').as('searchEntries')
//This is obviosly not working, but I don't get how to fix this.
let randomNumber = getRandomNumberBetweenTwoValues(0, this.searchEntries);
cy.get(this.SEARCH_RESULT + ' > a').eq(randomNumber).click()
Something like this could work. If this.searchEntries give undefined error then make the block function(){} instead of ()=>{}

Wrong Answer while doing concatenation in an ashx page

string name = id + '_' + pos + '_' + nextid;
This is my code in an .ashx page. My expected result is name=1_12_2 and i am getting it as name=2062.

SELECT * INTO Incomplete Query Clause

I seem to be doing something wrong in my OleDbCommand, but I don't know what it is. I am trying to create another table in my access database that is exactly the same as the first but with a different name, by copying everything from one and using SELECT INTO. I don't know why it doesn't work.
OleDbCommand copyAttendanceCommand = new OleDbCommand("SELECT * INTO '" + "Attendance " + DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year + "' FROM Attendance",loginForm.connection);
copyAttendanceCommand.ExecuteNonQuery();
The Error message that I get says "Syntax error in query. Incomplete query clause." Does anyone know what that means?
Table or field names with spaces are not specified with '' around them, but with square brackets.
Your command should be:
"SELECT * INTO [Attendance " + DateTime.Now.Day + "/" + DateTime.Now.Month + "/"
+ DateTime.Now.Year + "] FROM Attendance"
You may even format your date to make the code more readable:
string today = DateTime.Today.ToString("d'/'M'/'yyyy");
string sql ="SELECT * INTO [Attendance " + today + "] FROM Attendance";
OleDbCommand copyAttendanceCommand = new OleDbCommand(sql, loginForm.connection);
copyAttendanceCommand.ExecuteNonQuery();

How to insert line break in a return statement for D3

I have the following code d3 code:
tooltip.select("#popupCount").text(function(){
if (varToGraph == "rough_top_cost"){
return " " + textValue + ": $" + addCommas(allCountyData[countyName][varToGraph]) + "\n" +
"Count:"
}})
I want the word count to appear on a new line. However, the above code results in everything being on one line. How can I get the output to be on two lines?
Thanks,
AH
Untested answer, but FWIW this may get close;
tooltip.select("#popupCount").html(function(){
if (varToGraph == "rough_top_cost"){
return " " + textValue + ": <br/>$" + addCommas(allCountyData[countyName][varToGraph]) + "\n" +
"Count:"
}})
Working from the example provided on page 80 of D3 Tips and Tricks which includes tooltips with line breaks.
Uses html element instead of text which allows line breaks. Check out the document for more detail.

Carrying an ID with strings to a next page

I'm trying to carry the ID to the next page, but all i manage to get is review.php?ID= without the ID.
Here is the code:
html = html + "Name:" + name + "Type : " + type + "Location : " + location + '<input type="button" value="Write a review!" onclick=parent.location="review.php?ID=" ('+ ID +') />' + "<br/>";
Thanks in advance for any help.
There's a couple things wrong here. You have mismatched quotes (single and double), and I'm pretty sure the id shouldnt have spaces round it with parens. The embeded quotes need to be escaped, too
something like this:
html = html + "Name:" + name + "Type : " + type + "Location : " + location +
"<input type='button' value='Write a review!' onclick='parent.location=\"review.php?ID=("+ID+")\" />" + "<br/>";

Resources