473,587 Members | 2,543 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(TheD ate,e,top,left)
{
varActiveTBox = e
varTop = top
varLeft = left
var RefDate = new Date(TheDate)
varDays = RefDate.getTime () - (OneDay * (RefDate.getDat e()-1))
RefDate.setTime (varDays)
varDays = RefDate.getTime () - (OneDay * (RefDate.getDay ()))
RefDate.setTime (varDays)
var MnthDate = new Date(TheDate)
varDays = RefDate.getTime () + (OneDay * 15)
MnthDate.setTim e(varDays)
varCurrentMonth = varMonth[MnthDate.getMon th()+1] + " " +
MnthDate.getYea r()
CurrentDate = TheDate
ShowCalendar(Re fDate);
}

function Prev()
{
var pDate = new Date(CurrentDat e);
varpDays = pDate.getTime() - OneMonth;
pDate.setTime(v arpDays);
DatePicker(pDat e,varActiveTBox ,varTop,varLeft );
}

function Next()
{
var nDate = new Date(CurrentDat e);
varnDays = nDate.getTime() + OneMonth;
nDate.setTime(v arnDays);
DatePicker(nDat e,varActiveTBox ,varTop,varLeft );
}

function ShowCalendar(th eDate){
calendar.innerH TML = "";
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='calheade r'>" +
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=ShowDat e('"
varCal += DateLoop.getMon th()+1 + "/" + DateLoop.getDat e() +
"/" +
DateLoop.getYea r()
varCal += "') class='calday'> " + DateLoop.getDat e() + "</td>";
varDays = DateLoop.getTim e() + OneDay;
DateLoop.setTim e(varDays);
}
varCal += "</tr>"
}
varCal += "</table>"
calendar.innerH TML = varCal
}

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

calendar.innerH TML = ""
varActiveTBox.v alue = theDate
}
Jun 27 '08 #1
1 2185
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
5364
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 working on it but not making much progress. Is there any free code available anywhere? I know it...
6
31139
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 reinstalling several times the db2 runtime client w/ different options, we found on a technical forum...
3
11574
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 these validations no longer work. While there have been changes to the code in the meantime, I cannot...
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
31806
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 problem is put the current date into CompareValidator. So, I created a hidden text field in my aspx. ...
12
29441
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
12938
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 using c#.
21
3360
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 dd/mm/yyyy setting since that is what the computer is set to. I want to be able to enter a date in...
10
5799
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 on their region, I would set the date formats on form_load
30
5683
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 January 7, 2008), it stores it in the database as 1/7/08 instead of 7/1/08. Why is it like that...
0
7927
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7857
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8220
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
7981
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
6632
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5723
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3846
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2367
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
1
1457
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.