473,513 Members | 2,397 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date format DD/MM/YYYY

Yas
Hello I've got the following Javascript for a web calendar popup that
outputs the date in 4/24/2008 (m/d/yyyy).

How can i modify it to output dd/mm/yyyy e.g. 24/04/2008. So all
outputs are in this format. The system this runs on has the correct
date format (not US) so I would like the JavaScript to also use that
format.

Many thanks

The code
------------------------------------
var OneDay = 86400000
var OneMonth = (OneDay * 30)
var CurrentDate = new Date()
varCurrentMonth = ""
varMonth = new Array(12)
varMonth[1] = "January"
varMonth[2] = "February"
varMonth[3] = "March"
varMonth[4] = "April"
varMonth[5] = "May"
varMonth[6] = "June"
varMonth[7] = "July"
varMonth[8] = "August"
varMonth[9] = "September"
varMonth[10] = "October"
varMonth[11] = "November"
varMonth[12] = "December"
varActiveTBox = ""
varTop = "100"
varLeft = "100"

function DatePicker(TheDate,e,top,left)
{
varActiveTBox = e
varTop = top
varLeft = left
var RefDate = new Date(TheDate)
varDays = RefDate.getTime() - (OneDay * (RefDate.getDate()-1))
RefDate.setTime(varDays)
varDays = RefDate.getTime() - (OneDay * (RefDate.getDay()))
RefDate.setTime(varDays)
var MnthDate = new Date(TheDate)
varDays = RefDate.getTime() + (OneDay * 15)
MnthDate.setTime(varDays)
varCurrentMonth = varMonth[MnthDate.getMonth()+1] + " " +
MnthDate.getYear()
CurrentDate = TheDate
ShowCalendar(RefDate);
}

function Prev()
{
var pDate = new Date(CurrentDate);
varpDays = pDate.getTime() - OneMonth;
pDate.setTime(varpDays);
DatePicker(pDate,varActiveTBox,varTop,varLeft);
}

function Next()
{
var nDate = new Date(CurrentDate);
varnDays = nDate.getTime() + OneMonth;
nDate.setTime(varnDays);
DatePicker(nDate,varActiveTBox,varTop,varLeft);
}

function ShowCalendar(theDate){
calendar.innerHTML = "";
var DateLoop = new Date(theDate);

var varCal ="<table border='0' cellspacing='2' cellpadding='1'
class='calendar' style='left: " + varLeft + "px; TOP: " + varTop +
"px'>";
varCal += "<tr><td onClick=Prev() class='clicker'><</td>";
varCal += "<td colspan='5' align='center' class='calheader'>" +
varCurrentMonth +"</td>";
varCal += "<td onClick=Next() class='clicker'>></td></tr>";

for ( var r = 1; r <= 6; r++ ) {
varCal += "<tr>"

for ( var c = 1; c <= 7; c++ ) {
varCal += "<td align='right' onClick=ShowDate('"
varCal += DateLoop.getMonth()+1 + "/" + DateLoop.getDate() +
"/" +
DateLoop.getYear()
varCal += "') class='calday'>" + DateLoop.getDate() + "</td>";
varDays = DateLoop.getTime() + OneDay;
DateLoop.setTime(varDays);
}
varCal += "</tr>"
}
varCal += "</table>"
calendar.innerHTML = varCal
}

function ShowDate(theDate)
{
var myDate = new Date(theDate)

calendar.innerHTML = ""
varActiveTBox.value = theDate
}
Jun 27 '08 #1
1 2174
Yas schreef:
<snip>

Hi Yas,

We all saw your posting from 3 hours ago just fine.
No need to repost the same question so fast.

If you are lucky somebody fixes your code.
I will not fix it because it is so basic.
You should be able to do it yourself, which you didn't try.
(At least you didn't show us anything.)

I don't want to be rude, or lecture you, but....
In general, just asking to fix your problem in a newgroup doesn't result
in a solution/many responses.
People think you are lazy, and should do it yourself.
(We get paid most of the time to fix other peoples problems, you know..)

However, if you ask something after trying yourself, AND show us what
you tried, you might get much better responses.

(Just a freindly word of advise.)

Regards,
Erwin Moller
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5345
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and calculate days, months, and years. This is not for a college course. It's for my own personal genealogy website. I'm stumped about the code. I'm...
6
31128
by: Dario Di Bella | last post by:
Hi all, we have the following urgent issue affecting our development team. Initially we had one particular workstation that failed executing queries on a DB2 database, raising an invalid date format exception (SQLSTATE=22007). The same queries worked fine on all the other workstations. The date format we want to use is "dd/mm/yyyy".After...
3
11569
by: Lyn | last post by:
Hi, I am developing a project in which I am checking for records with overlapping start/end dates. Record dates must not overlap date of birth, date of death, be in the future, and must not overlap existing records from the same table. I had this all working some time ago, but recently when I have gone back to do more testing, part of...
5
816
by: Macca | last post by:
Hi, I have a table which has a date/time field. I am storing them as follows :- 01/01/2005 11:25 01/01/2005 19:44 02/01/2005 05:04
7
31794
by: James P. | last post by:
Hello there, In my asp.net page using VB, I have a date text field in mm/dd/yyyy format. When a date is entered, I'd like to validate it to make sure the date is greater than or equal to the current date. If not, I'd like to display the error message to ValidationSummary. It seems to make sense to me to use CompareValidator but the...
12
29423
by: Assimalyst | last post by:
Hi, I have a working script that converts a dd/mm/yyyy text box date entry to yyyy/mm/dd and compares it to the current date, giving an error through an asp.net custom validator, it is as follows: function doDateCheckNow(source, args) { var oDate = document.getElementById(source.controltovalidate); // dd/mm/yyyy
9
12932
by: Alok yadav | last post by:
i am using a webservice in which a method is serach. i use this method which accept a argument of date type in dd/MM/yyyy formate. i have a textbox which accept the date from the user, when i convert textbox data into Datatime formate it converted into MM/dd/yyyy formate, but i have a requirement in dd/MM/yyyy formate. please help me, i am...
21
3337
by: Darin | last post by:
I have an applicatoin that works 100% perfect when running on a machine setup for English (United States), but when I change it to Spanish (Mexico), the dates start giving me fits. THe reason is USA is mm/dd/yyyy and mexico is dd/mm/yyyy. So, with the computer set to mexico, any standard CDATE function is going to return the date in the...
10
5787
by: ARC | last post by:
Hello all, General question for back-end database that has numerous date fields where the database will be used in regions that put the month first, and regions that do not. Should I save a date format in the table design, such as: mm/dd/yyyy? What I've done for years is to store the date format in date fields, then on the forms, based...
30
5646
by: fniles | last post by:
On my machine in the office I change the computer setting to English (UK) so the date format is dd/mm/yyyy instead of mm/dd/yyyy for US. This problem happens in either Access or SQL Server. In the database I have a table with Date/time column. The database is located on a machine that is set to dd/mm/yyyy also. When I enter date 7/1/08 (as in...
0
7177
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7394
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7559
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7123
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7542
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5701
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4756
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3248
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
1611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.