Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm doing a bank oriented project. I have to generate Account Number using current date.
Example:
account no-20150409001.
'2015'-Year,
'04'-Month,
'09'-Date,
'001'-represents the number of the new member opening the account on that particular date
This number should change in every branch to avoid same account number.
How to do so?
and this is my code
http://jsfiddle.net/Jegannath/z9na41o5/#&togetherjs=ynHxlyDeO1
If this is really a bank related project, do not rely on client side JavaScript for something as critical as the account number generation.
Is there a reason for the "random" number requirement? If not, stick with a sequence, it is a lot easier to ensure uniqueness.
On the server side, using a branch prefix as suggested by #kuldeep.kamboj should cover collision.
You can use something like yyyyMMddBBnnnn where yyyy = year, MM = month, dd = day, BB = branch number, and nnnn as a sequence that resets per day.
Not sure,this is correct advise,
Go with branch code prefix and timestamp in suffix, this might be developer friend also, because in future after 30 year easily you can tell his account created date with the help of timestamp.
As well timestamps is kind of random number.
advisable is server side code.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 months ago.
Improve this question
I have an API which returns a list of objects. Each of these objects have a field called timeOut which contains some time interval in secs. Once the time interval of any object expires, some operation needs to performed on that particular object.
How can I achieve this in react ? I considered using setInterval on each object in the list, but it looks like a bad design.
Any help will be appreciated. Thank you.
You should use setTimeout instead of setInterval if you want an operation to run only once after the given time period. I believe this is your best bet to accomplish this task.
Otherwise, you will have to dive into even crazier designs like comparing the present date-time object from new Date() with the one you generated right after fetching your data, which will not only be complicated but also, more error-prone and inaccurate.
Let me know if you want help with the first method.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I created a webshop for an online game where the users can buy in-game stuff. I have some special items which will be only availabe for a short period of time and I want to print out how much time left to buy it.
I wrote a JS code to countdown for a date, and now I want to store it in the database. Which is the best way to do it? Just a varchart with extremely long length? Or is it a more elegant way to deal with this?
You can use Function.prototype.toString method to convert a function into a string and then later use eval to execute the function.
You should use text type rather than varchar as it will likely be longer than maximum varchar length.
However, I would strongly discourage you to do this. A better approach would be to store something like a expiration date timestamp and calculate the availability based on that value.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Hello and thanks in advance for looking at my problem. I'm trying to create a web interface for a time lapse project I'm doing right now, but I don't know exactly where to start with this.
What I have
A website, obviously;
A lot of pictures, made every 15 minutes;
Stored in folders (/mm-yy), saved as dd-mm-yy_hhmm.jpg.
What I'm looking for
I want to be able to select a date with a datepicker, which returns all the pictures taken on that particular day so I can show only those pictures on the site.
I've been searching around but I have troubles finding out what the best solution is and where to start. I don't have a lot of experience with JavaScript. I thought maybe create a JSON-file with all the images (regenerated every 15 minutes) and use that in some way with a datepicker?
Any ideas, tips and/or tricks?
There are numerous ways to approach this but since you tagged php my first impulse would be something akin to:
Walk the directory tree to find all represented months
For a given month build your date list using regex - this will let you pull out the date matches you need
Create your date picker using one of the many, many javascript options
IIWM I wouldn't mess about with a separate file the gets regenerated. Do your population when the page opens.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I am building a front end component to allow users to choose a date\time range and optionally use time periods as per the ISO 8601 specification.
The component will need to bind to any existing values already set by the user, and so I am looking at how to parse out the time interval period piece for a string such as:
"2007-03-01T13:00Z/P1Y2M10DT2H30M"
I am unsure how to extract the numerical parts of the time interval piece so I can get some sort of object\array, keyed by the letters perhaps so I can easily determine number of years (Y), months (M), etc.
I could have a go at my own regex, but I suspect someone out there has already done this.
I'm wanting to give users a series of number inputs and just set these for any existing period values the user has set previously.
Can anyone suggest any approaches here?
I hope this makes sense!
Thanks
Try this:
var dateStr = '2007-03-01T13:00Z/P1Y2M10DT2H30M';
var date = new Date(Date.parse(dateStr.split('/')[0]));
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am working on an application to get historical stock data from yahoo finance csv api. I am having trouble creating a script that will get the current day and count back 23 weekdays (not counting weekends or holidays). The idea is that it will plug the two dates in at yahoo, get the historical data and then create a moving average. I am unsure how to do this using the date function though.
You could use the Moment.js library, if you are able to provide that to your page. You could use it to do something like this:
var today = moment();
var pastDate = today.subtract('days', 23);
// then do something with those two variables...
if you need them in a certain format before you pass them along, just call .format on them
getHistoricalData(today.format('YYYYMMDD'), pastDate.format('YYYYMMDD'));