Trying to filter the days it will be done but the problem is changing the days change code also my requirement is to add the configuration for this if change the days in the configuration it will be a filter.
app settingsjson
"Cashbacksettings": {
"Startdate": "15"
}
configuration injected from the base controller to the controller
var StartDate = Configuration.GetSection("Cashbacksettings").GetSection("Startdate").Value;
the value will be hit but the output did not come.
please any solution for this? Thanks.
Related
I'd like to build a website which has the following features:
There should be a few fields which store numerical values.
These fields should be editable by anyone who visits the site
A second order feature which would be nice, but isn't necessary
It would be nice if when multiple people are visiting the site and one visitor updates a value, the webpage reloads for all visitors once the value is saved, updating the value seen for all users
How would I go about implementing the above?
I'm not sure what terms I should even be googling to approach this question, so any advice is appreciated.
To your first question:
const editMe = document.getElementById('edit-me');
editMe.addEventListener('input', () => {
const editedToInt = Number(editMe.innerHTML);
if (!Number.isInteger(editedToInt)) {
// Value is invalid
editMe.style.border = "2px solid red";
}
else {
// Value is valid. Do something with it...
editMe.style.border = "inherit";
}
})
<div id="edit-me" contenteditable>100</div>
The user can edit the content and only numbers are allowed.
To your second question:
You could save the value which the user has typed in your database. Also you need to use Ajax to check the value in your database every 5 seconds. If the value in your database is different than the value in the DOM, you will replace it.
In my application, a user can specify a date in a form, via a datepicker. Doing so, the date has this format : "2018-05-16T12:45:30Z".
Then, I want to store it in a MySql database, in a TIMESTAMP column.
Later, the user can edit his data. Consequently, the datepicker has to be initialized with the date coming from the server, previously saved.
To manage this, I created an accessor and a mutator :
public function setDateNameInputAttribute($value)
{
$this->attributes['date_name_input'] = Carbon::createFromFormat('Y-m-d\TH:i:s\Z', $value);
}
public function getDateNameInputAttribute($value)
{
return Carbon::parse($value)->format('Y-m-d\TH:i:s\Z');
}
This code works fine : my front-end reads UTC (Zulu) dates and I can insert timestamps in my database.
However, it's not perfect.
Let's say I need for whatever reason to add one hour to a stored date
$myObject = MyClass::find(1);
$theDate = $myObject->dateNameInput;
Now $theDate is a "T Z format" string, because of the accessor. I could recreate a Carbon object to do my addition, but I think this Carbon -> string -> Carbon transition would be ugly. How can I make a nice operation ?
If my applications contains a lot of input dates, with many different model names, is there a way to generalize my accessor and my mutator ?
Actually, is my first approach good ?
Thanks for reading !
Its confusing me. I've a property in my Model which is annotated with DateTime. In my Database its stored as timestamp. In Frontend I use the f:format.date viewhelper to output this property.
When I create a new record, and add f.e. 01.06.2017 10:00 in this field, in my database is stored the timestamp for 01.06.2017 08:00. In Frontend the output is correct. Until here everything is fine.
The last timechange in March lead to a + of two hours in output. I assume in October that will change again and the output will be than this: 01.06.2017 08:00.
How can I prevent this. Its definitely a problem when these dates change, because its important for the business.
How can I test what will happen in October?
The Problem occurs as TYPO3 saves times normalized as UTC. for normalization (and afterwards denormalization) it respects the timezone-settings of the server. Or settings given in LocalConfiguration.php.
Up to 6.2 there were two settings [SYS][serverTimeZone] and [SYS][phpTimeZone].
With 7.6 it is only [SYS][phpTimeZone] as the servertimezone is detected from php itself.
You now have the option to fake the timezone of your server to "UTC" by setting [SYS][phpTimeZone] to the string "UTC". In this way no times should be changed any more.
TYPO3 9.5 and newer
Use the environment (documentation)
// use TYPO3\CMS\Core\Utility\GeneralUtility;
// use TYPO3\CMS\Core\Context\Context;
$context = GeneralUtility::makeInstance(Context::class);
// Reading the current data instead of $GLOBALS
$currentTimezone = $context->getPropertyFromAspect('date', 'timezone');
$currentTstamp = $context->getPropertyFromAspect('date', 'timestamp');
$current = new DateTime('#'.$currentTstamp);
$current->setTimezone(new DateTimeZone($currentTimezone) );
In Fluid you may use a DateTime-Object:
// in PHP-ode of Viewhelper
//...
$this->registerArgument('date', 'mixed', 'Either an object implementing DateTimeInterface or a string that is accepted by DateTime constructor');
// ...
In HTML
{dateTimeObject -> f:format.date()}
<f:format.date format="d.m.Y">{dateTimeObject}</f:format.date>
In my Apps Script, I need to use the same format of (yesterday's) date in multiple different functions. So I decided to make my own custom makedate() function to reliably create this date for me when I needed it. The issue, however, is that it's returning undefined instead of my date. Here is my current function:
function makeDate(){
var myDate = new Date();
var date = (myDate.getDate()-1) + "-" + (myDate.getMonth() + 1) + "-" + myDate.getFullYear();
Logger.log(date);
return date
}
In the log file, I see that the date is being created in the format I want. However, when I then make another function to test the return value, the log file shows Made date: with no date following it, and other uses show that the value is undefined. What am I doing wrong?
your issue is that custom functions return value must not depend on anything other than input parameters. in your case you have none so it will cache the first result and use it for further calls with the same parameters (none).
to fix you must pass the date as a parameter.
I figured out the problem somehow had to do with variable scopes I think actually. I was using this to test code for another script within the project, not realizing that the functions within the scripts are all connected. Once I made sure there was only one instance of every function/global, the problems resolved. Dumb mistake, I know, but it's good to know for any beginners learning Google Apps Scripts so I figured it was worth posting as an answer.
Developing a component for Joomla v2.5, I'm using a table with a mysql timestamp column.
One of the component's settings is the "Timezone". I don't want to use server timezone, as code will run on different servers/timezones and I want to be indepedent. So the idea is to store timestamps in mysql, and display the correct date/time according to the component's parameter. The main drawback is the timezone that mysql server uses, that make the whole situation complicated. So, is there a way to store current timestamp in an universal format in MySQL and display it in the correct way?
The ultimate goal is for the component to be able to display the correct date/time based on the component's parameter, eg. user changes the parameter on the fly, no modification on the database take place, only on the "View"
In order to display the date in the correct timezone I use this:
JHtml::date($date_from_mysql , 'd/m/Y H:i:s', $my_component_timezone_parameter)
Please share your thoughts.
try
jimport ('joomla.utilities.date');
$date = new JDate($mydate);
$curdate = $date->toFormat('%Y-%m-%d %H:%M:%S');
for timezone settings
try http://docs.joomla.org/JDate::setTimezone/1.6
http://www.webamoeba.co.uk/site/index.php/articles-joomla-date-time
or try to override the store method in your table class:
public function store($updateNulls = false)
{
// get date
$date = JFactory::getDate();
// set variable for timestamp
$this->myDate = $date->toMySQL();
return parent::store($updateNulls);
}