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 9 years ago.
Improve this question
I have an HTML text box () for input time that is in hh:mm format (h: hour and m: minute). I would like user to input the time in that format. How can I achieve that by using jQuery or some JavaScript codes? Thank you.
There are many jQuery plugins that do input formatting/validation. A tricky part might be to come up with a regular expression that validates correct times. This example is pretty flexible:
^([01]?[0-9]|2[0-3]):[0-5][0-9]$
It allows the first 0 to be optional, and ensures that hours don't go above 23. It also makes sure that the minutes are between 00 and 59.
Depending on how you parse your result, you might want to be more restrictive. For instance, you could remove the ? from the regex to force HH:MM format, and still ensure that hours are between 00 and 23, while minutes are between 00 and 59. It looks like that:
^([01][0-9]|2[0-3]):[0-5][0-9]$
Use this regex to validate time in hh:mm format.
^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$
You might have to edit for your specific use case.
Here is a fiddle http://jsfiddle.net/ENz9p/27/
source: How to validate a time user input like hh:mm to hh:mm in javascript?
There are a few ways to do it in js (Date.parse), but I think moment.js is the easiest (most robust) way out there.
http://momentjs.com/
Related
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 2 years ago.
Improve this question
Can someone please explain how those lines code works?
setInterval() executes function over and over. This function:
Declares variable birthday with future date as a reference and
converts it to special format (milliseconds since UNIX epoch)
Declares variable now with current moment converted to same special
format.
Declares variable distance with difference between above two.
That is, distance holds milliseconds left to birthday.
Populates DOM elements (days, hours, minutes, seconds) with time left to birthday
When difference becomes zero, it populates DOM elements (headline) with "It's my birthday" text and makes it visible (sets its style attribute) and at the same time makes counter invisible.
it will continue running while the browser open, and will show :
It's my birthday
on 30 september 2021 at 00:00:00
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 5 years ago.
Improve this question
the original input field display is hh:mm am/pm, I got some CSS codes that turned the display into hh:mm:ss, but it won't display 00:--:-- even if the input value is 00:--:--, instead it displays 12:--:--. is there a way to fix this? perhaps by CSS or JS?
edit: is there another way to have a similar styled input field that takes input in the form of hh:mm:ss into "hh:mm:ss"?
If you are using -
<input type="time" name="time" />
Then Chrome may not display it in 24 hour format but other browsers may.
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 needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I'm trying to add two times in this format:
HH:MM:SS
eg: 12:31:32 and 01:32:39
I want to write a script that adds times and the result of which must be in the same format.
How would you tell the script to add up the first two digits before : (hours) and then the two between the two semicolons (minutes) and then seconds?
I don't want anyone to make the script I just want to know how it could be made.
If they are strings var time1 = "1:23:25" then you will need to convert it into something else to work with it.
You can do it manually, by splitting the string into an array and adding the numbers and handling any overflow (>60 seconds to increase minutes etc) and then joining the hours, minutes and seconds back together to create a new string.
You can also convert each to a Date which you can just add together like they were numbers eg:time3=time1+time2 you can then format the result back into the original format.
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.