Support Forum Softcomplex logo
About Us  | Services  | Download  | Order  | Support  | |
| Search | Today's Posts | Stats | Board Rules | Not logged in [ Login | Register ]
go to bottom
Last active: Never

Printable Version | Subscribe | Add to Favourites   Post new thread
Author: Subject: Rearrange Date Format
Kimura
Newbie

Posts: 1
Registered: 2/5/2005
Member Is Offline
posted on 2/5/2005 at 01:13 AM Reply With Quote
Rearrange Date Format


To start Great App!

I was wondering how to configure the date error handling to support MySQL date fromat
(yyyy-mm-dd)?

I rearranged the date format but if I try to change the date by launching the calendar again I get an error "Invalid day of month value: '2005' Allowed range .... It is still check the first digits as the day.

Can you help me correct this, Javascript isn't really my bag... Any assistants is greatly appreciated
View User's Profile View All Posts By User U2U Member
rahulmunjal
Newbie

Posts: 1
Registered: 2/14/2005
Location: bangalore
Member Is Offline
posted on 2/14/2005 at 06:56 AM Reply With Quote
Same Question


I also need to change the date format to yyyy-mm-dd
Please suggest the changes.
View User's Profile View All Posts By User U2U Member
skimonkey
Junior Member

Posts: 2
Registered: 4/7/2005
Member Is Offline
posted on 4/7/2005 at 01:31 AM Reply With Quote

Here are the functions that need to be changed for mysql:
// date generating function
function cal_gen_date2 (dt_datetime) {
return (
dt_datetime.getFullYear()
+ "-" +
(dt_datetime.getMonth() < 9 ? '0' : '') + (dt_datetime.getMonth() + 1)
+ "-" +
(dt_datetime.getDate() < 10 ? '0' : '') + dt_datetime.getDate()
);
}

// date parsing function
function cal_prs_date2 (str_date) {

var arr_date = str_date.split('-');

if (arr_date.length != 3) return alert ("Invalid date format: '" + str_date + "'.\nFormat accepted is dd-mm-yyyy.");
if (!arr_date[1]) return alert ("Invalid date format: '" + str_date + "'.\nNo day of month value can be found.");
if (!RE_NUM.exec(arr_date[1])) return alert ("Invalid day of month value: '" + arr_date[1] + "'.\nAllowed values are unsigned integers.");
if (!arr_date[0]) return alert ("Invalid date format: '" + str_date + "'.\nNo month value can be found.");
if (!RE_NUM.exec(arr_date[0])) return alert ("Invalid month value: '" + arr_date[0] + "'.\nAllowed values are unsigned integers.");
if (!arr_date[2]) return alert ("Invalid date format: '" + str_date + "'.\nNo year value can be found.");
if (!RE_NUM.exec(arr_date[2])) return alert ("Invalid year value: '" + arr_date[2] + "'.\nAllowed values are unsigned integers.");

var dt_date = new Date();
dt_date.setDate(1);

if (arr_date[1] < 1 || arr_date[1] > 12) return alert ("Invalid month value: '" + arr_date[1] + "'.\nAllowed range is 01-12.");
dt_date.setMonth(arr_date[1]-1);

if (arr_date[0] < 100) arr_date[0] = Number(arr_date[0]) + (arr_date[0] < NUM_CENTYEAR ? 2000 : 1900);
dt_date.setFullYear(arr_date[0]);

var dt_numdays = new Date(arr_date[0], arr_date[1], 0);
dt_date.setDate(arr_date[2]);
if (dt_date.getMonth() != (arr_date[1]-1)) return alert ("Invalid day of month value: '" + arr_date[2] + "'.\nAllowed range is 01-"+dt_numdays.getDate()+".");

return (dt_date)
}

Should be able to cut and paste. The only thing I changed was the ordering of things(ie array's etc).
View User's Profile View All Posts By User U2U Member
bigbro
Newbie

Posts: 1
Registered: 9/7/2005
Member Is Offline
posted on 9/7/2005 at 02:07 PM Reply With Quote

i think your reply is for mm-dd-yyyy, how do you change it for yyyy-mm-dd? thanks.
View User's Profile View All Posts By User U2U Member
skunk
Newbie

Posts: 1
Registered: 9/12/2005
Location: South Africa
Member Is Offline
posted on 9/12/2005 at 04:21 PM Reply With Quote
Please help


What a wicked app! It is proving very usefull, I have run into the same issue as bigbro who posted a question (9/7/2005) on how to change the date format for MySQL...I tried shuffling the arrays around but I got quite dizzy in the process... I'm not a javascript pro, please would you be so kind as to explain to me how I can change the date and time format to display in the following way: dd-mm-yyyy hh:mm:ss and mm-dd-yyyy hh:mm:ss?

A simple explination would be a great help please.

Many thanks
View User's Profile View All Posts By User U2U Member
peer
Newbie

Posts: 1
Registered: 6/22/2006
Location: Greece
Member Is Offline
posted on 6/22/2006 at 07:50 AM Reply With Quote

Quote:
Originally posted by skimonkey
Here are the functions that need to be changed for mysql:
// date generating function
function cal_gen_date2 (dt_datetime) {
return (
dt_datetime.getFullYear()
+ "-" +
(dt_datetime.getMonth() < 9 ? '0' : '') + (dt_datetime.getMonth() + 1)
+ "-" +
(dt_datetime.getDate() < 10 ? '0' : '') + dt_datetime.getDate()
);
}

// date parsing function
function cal_prs_date2 (str_date) {

var arr_date = str_date.split('-');

if (arr_date.length != 3) return alert ("Invalid date format: '" + str_date + "'.\nFormat accepted is dd-mm-yyyy.");
if (!arr_date[1]) return alert ("Invalid date format: '" + str_date + "'.\nNo day of month value can be found.");
if (!RE_NUM.exec(arr_date[1])) return alert ("Invalid day of month value: '" + arr_date[1] + "'.\nAllowed values are unsigned integers.");
if (!arr_date[0]) return alert ("Invalid date format: '" + str_date + "'.\nNo month value can be found.");
if (!RE_NUM.exec(arr_date[0])) return alert ("Invalid month value: '" + arr_date[0] + "'.\nAllowed values are unsigned integers.");
if (!arr_date[2]) return alert ("Invalid date format: '" + str_date + "'.\nNo year value can be found.");
if (!RE_NUM.exec(arr_date[2])) return alert ("Invalid year value: '" + arr_date[2] + "'.\nAllowed values are unsigned integers.");

var dt_date = new Date();
dt_date.setDate(1);

if (arr_date[1] < 1 || arr_date[1] > 12) return alert ("Invalid month value: '" + arr_date[1] + "'.\nAllowed range is 01-12.");
dt_date.setMonth(arr_date[1]-1);

if (arr_date[0] < 100) arr_date[0] = Number(arr_date[0]) + (arr_date[0] < NUM_CENTYEAR ? 2000 : 1900);
dt_date.setFullYear(arr_date[0]);

var dt_numdays = new Date(arr_date[0], arr_date[1], 0);
dt_date.setDate(arr_date[2]);
if (dt_date.getMonth() != (arr_date[1]-1)) return alert ("Invalid day of month value: '" + arr_date[2] + "'.\nAllowed range is 01-"+dt_numdays.getDate()+".");

return (dt_date)
}

Should be able to cut and paste. The only thing I changed was the ordering of things(ie array's etc).




The above script DOES NOT work at all !

To make it work and get mySQL syntax (yyyy-mm-dd) you have to cut and paste the above functions into calendar1.js and replace with a text editor

date2 to date1

Cheers!
View User's Profile View All Posts By User U2U Member
Post new thread

Related Links:
Product Page
Product Demonstrations Live Demos
Free Download Free Download
Product Documentation Documentation
Support Forum Support Forum
 

Go To Top


Powered by XMB 1.9.1 Nexus
Developed By Aventure Media & The XMB Group © 2002-2004