Qweb/odoo 9-Convert datetime to time - odoo

How to Convert datetime to time in qweb report. Now return 2016-11-03 07:40:55 I want only 07:40:55
My solution is not working:
<span t-esc="o.start" t-field-options='{"format": "hh.mm.ss"}'/>

Change t-esc to t-field. t-field-options only works on t-field.

Related

Xpath or cssSelector for displaying current time

enter image description hereI am trying to get current time with either cssSelector or xpath.
I am able to get curren time using: .is-today as cssSelector directly in date picker.
Can we call current time or current time plus certain minute using cssSelector or xpath?
As image show today's date has been capture with .is-today
html is
<div class="listContainer svelte-ux0sbr” xpath=“1”>
<div class="item svelte-bdnybl" xpath="1">09:05 AM</div></div>

Trying to click labels inside input

html code:
<input id="19eb0353-6208-4baa-8f89-f7af0a6edb91" type="date" placeholder="Date of Birth" value="" name="dateOfBirth" data-componentname="dateOfBirth" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" data-ddlabel="dd" data-mmlabel="mm" data-yyyylabel="yyyy">
ID is dynamic
Trying to enter the day month and year but not sure how to write it
I know this is the data but cant find anything on selecting these specific labels inside the input
data-ddlabel="dd" data-mmlabel="mm" data-yyyylabel="yyyy"
Tried Xpath, css selector but the ID is dynamic
You can use the below css.
input[type='date']
or the below xpath
//input[#type='date']
Screenshot:
when registration page opens (after clicking join now), you can use xpath like "//select[#id='nike-unite-date-id-mm']" to select date, month and year separately (like dropdown).
OR
you can directly point to specific date using xpath
"//select[#id='nike-unite-date-id-mm']//option[contains(text(),'10')].click()"
this will directly select the date, similarly can be done for months and year by changing #id
Please use below code.
I have tested, it worked for me.
driver.findElement(By.xpath("//input[#type='date']")).sendKeys("04/04/1989");
Please let me know if you face any error.
You can try this (example using python):
from selenium.webdriver.support.ui import Select
month = Select(driver.find_element_by_id('nike-unite-date-id-mm'))
month.select_by_visible_text("08")
day = Select(driver.find_element_by_id('nike-unite-date-id-dd'))
month.select_by_visible_text("21")
year = Select(driver.find_element_by_id('nike-unite-date-id-yyyy'))
month.select_by_visible_text("2019")
And use Select Method like this:
<option value="01"> 01 </option>
^^
select_by_visible_text("01")
<option value="01"> 01 </option>
^^^^^^^^^^
select_by_value("01")

how to get part of date qweb odoo

The date in my Invoice is currently showing as:
21/11/2014 16:59:15
I want to show just month something like this:
11
I tried using t-esc with strftime but that doesn't work:
<span t-esc="o.date_order.strftime('%m')" />
Try:
<span t-field="o.date_order" t-field-options='{"format": "MM"}'/>
More on supported format patterns.
Try This.
<span t-esc="datetime.datetime.strptime(o.sale_id.confirmation_date, '%Y-%m-%d %H:%M:%S').strftime('%B %d,%Y')"/>
My Output is: May 28,2018
Hope, It will be use.

WebMatrix - US date/time format proving to be an issue

I am creating a UK-based website, so users on my site will typically be used to the format dd/mm/yyyy. I have created a datepicker for the users to use, and it works fine, until i pick the 13th day, (13/10/2013). I'm guessing the database is seeing this as a US date, and thus there are not 13 months in a year.
What do i need to do to my code to convert this to the correct format, or change my databse to use UK format? What's easiest?
if(IsPost){
var dateis = Request["date"];
var insert = "INSERT INTO TestTable (testdate) VALUES (#0)";
var qinsert = db.Execute (insert, Request["date"]);
}
}
<div class="container">
<h1>Bootstrap Datepicker</h1>
<form method="post">
<div class="input-append date" id="dp3">
<input class="span2" name="date" size="16" type="text" value="">
<span class="add-on"><i class="icon-th"></i></span>
</div>
<button class="btn btn-success" type="submit" value="Submit"/>Submit</button>
</form>
</div>
<script type="text/javascript">
$('#dp3').datepicker({
format: "dd/mm/yyyy",
autoclose: true,
todayHighlight: true
})
</script>
I personally use the format d MM yyyy for datepickers (eg '14 November 2013'). It takes up more space, but to me it's more readable and completely sidesteps the dd/mm/yyyy vs mm/dd/yyyy issue.
If you want to keep it the way it is, as long as your development machine and server machine is correctly configured for UK times, you can use the AsDateTime() extension method which should resolve the issue.
var qinsert = db.Execute (insert, Request["date"].AsDateTime());
As Mike points out in another answer, this isn't best practise though - having code that is reliant on server setup and the like can easily come back to haunt you.
Generally, you are best advised storing dates in yyyy/mm/dd hh:mm:ss format. That way there is no problem with regional variations. Also, if your app is global, you might want to consider using UTC so that there are no issues with varying server times.

Setting Date text object with correct formatting string

I can not figure out the secret format string to get my time displayed into a time text box. The time is stored in the database in this format '10:30 AM' DeliveryTime is defined as a string in the database. I have tried various versions similar to this below to no avail. Please help.
<input type="time" id="DeliveryTime" name="DeliveryTime" class="form-control" value="#Model.DeliveryTime.ToString("hh:mm tt")">
Looking at the format of the value in the database (10:30 AM) and the format you are trying to use: hh:mm tt, they are the same.. so all you need to do is display it directly:
<input type="time" id="DeliveryTime" name="DeliveryTime" class="form-control" value="#Model.DeliveryTime">
Or am I missing something here?