using date_format in fetch url variable in smarty - smarty

{$GLOBALS.settings.listing_last_updated_date} gets date from db in format
Aug 4, 2016
I need date output as |date_format:"%m.%d.%Y" ie. 08.04.2016
{fetch file="http://`$smarty.server.HTTP_HOST`/latest/?action=search&activation_date[not_less]=`$GLOBALS.settings.listing_last_updated_date|date_format:"%m.%d.%Y"`" assign='last_updated_date'}
Wherever I use {$last_updated_date} I should get fetched content from http://mysite/latest/?action=search&activation_date[not_less]=08.04.2016
The actual problem is using date format |date_format:"%m.%d.%Y" is not working in fetch variable.

It won't work that way, Try to generate the date in a separated variable and then add it to the url:
{$last_update=$GLOBALS.settings.listing_last_updated_date|date_format:"%m.%d.%Y"}
{fetch file="http://`$smarty.server.HTTP_HOST`/latest/?action=search&activation_date[not_less]="|cat:$last_update assign='last_updated_date'}

Related

Vue.js - Laravel Populating datetime-local input field

I'm trying to populate my Vue.js Template to update a model
<input type="datetime-local" name="start_time" v-model="start_time">
Having issues pre filling the date-time field
start_time: "2020-02-12 22:00:00"
this is the data that i receive from api and i'm directly assigning it to my start_time variable
Just adding to the answer
use format
'YYYY-MM-DDTHH:mm'
otherwise there will be an issue with AM and PM
According to the MDN web docs for datetime-local the format should be yyyy-mm-ddThh:mm. Therefore you'll need to update the value of your data property to be:
2020-02-12T22:00
Since you've using moment you can format the initial date with:
moment(dateString).format('YYYY-MM-DDThh:mm')
Replace dateString with the actual date string or property that contains the date string.

datetime value convert on variable save

I am trying to save a date as an octopus variable
The date format is like 2019-05-26T00:00:00+00:00
But while trying to save this octopus is automatically converting it into 05/25/2014 20:00:00 this formart.
Please suggest any way to save the variable in the original(i.e. 2019-05-26T00:00:00+00:00) format
You can use a filter to format the datetime correctly like this:
"#{Time | Filter "yyyy-MM-ddTHH:MM:ss"}"

Can't remove hours and minutes from datatable

I'm trying to get release date field with y-m-d format.. Actually time format (for y-m-d) seems fine but also it gives h:m:s too, I changed time format at server side and removed h:m:s but datatable still shows them
What I get
2012-04-11 00:00:00
What I want
2012-04-11
Released_at field (Metronic theme - json datatable)
{
field: "released_at",
title: "Release Date",
type: "date",
format: "YYYY/MM/DD"
}
time format (I'm using laravel framework)
protected $dateFormat = "Y-m-d";
How do I fix this ?
Datatable accept column type same as mysql type.
You are trying to convert mysql dateTime column to Date in datatable, which is not possible from datatable.
In your code you have declared
format: "YYYY/MM/DD" // but actual type is dateTime as per mysql.So it will append time next to it.
If you are storing only date in mysql then you can change column type to Date, and your problem gets solved.
And if you want to convert string to date in laravel you can follow this post.
Your database column is of type dateTime which, by definition, includes both date and time information. If you want to remove the time at a database level then use the date type instead
$table->date("released_at")->nullable();
If instead of removing the time from the database, you just want to ignore it for certain parts of your application, you can leverage the fact than in Laravel all dates coming from your models are Carbon\Carbon instances, so you could do
$model->releasedAt->format('y-m-d'); // Returns '18-09-11'

update the date within the url of a csv, prior to downloading it

I have a ruby script that downloads a csv file with an embedded date i.e.
File.write("directory/my.csv",Net::HTTP.get(URI.parse("https://exampleurl.csv2017-06-26")))
*the actual url is very long.
I want to run that code weekly to update the data, but the date of the download is embedded within the URL.
How can I split the url, update the date, and join it back together, prior to running the code?
Use substitute:
a = s.sub(/\d{4}-\d{2}-\d{2}/,"2017-01-01")
or split:
s="abc2017-10-10def"
a = s.split(/\d{4}-\d{2}-\d{2}/)
url = a[0]+"2017-11-10"+a[1]
If the date is only at the end, use:
url = a[0]+"2017-11-10"

Comparing dates in Xpath with different formats

I have a date in this format "21-Mar-2014"
I already tried to search for Xpath formulas but with no use
I am getting the first format 21-Mar-2014 using SeleniumIDE and want to check if this value is the date of today,
So how can xpath generate today's date and compare it for the date extracted using Selenium
You can parse the string into a date with an xpath function such as date:date(string) (described in this question).
Today's date already in xml date format is supplied by fn:current-date() (see here)
You can get the value, sore it in a variable, and then compare it. Eg:
storeText //xpath/goes/here myDate
storeEval (new Date(storedVars['myDate']) > new Date()) isAfterToday
Note, the storedVars array holds all the variables.
new Date should parse most formats, otherwise you can use any javascript in the storeEval stage to reformat it.

Resources