A handy date function 
Author Message
 A handy date function

Hello folks

If you like me send dates from client to server as strings, to go into a
database, you'll know that DateValue needs a certain format. Here's a
function (first draft?) to help-

function date_to_DateValue(datetime) {

 var splitdatestring

 splitdatestring = split(datetime.toString(), " ")

 return splitdatestring(1) + " " + splitdatestring(2) + " " +
    splitdatestring(5) + " " + splitdatestring(3)

 // toString gives this format: Tue Feb 6 19:00:00 UTC+1100 2001
 // Note 19:00 so am/pm is preserved
 // this function returns (from 0 to 5) 'word' 1, 2, 5, 3
 // in this case Feb 6 2001 19:00:00
 // DateValue understands this format

Quote:
}

cheers
J


Fri, 25 Jul 2003 17:51:29 GMT  
 A handy date function
Um, it's late here (where' the delete button on this thing..)
Try again-

function datetodatevaluestring(datetime) {

 var splitdatestring

 splitdatestring = datetime.toString().split(" ")

 return (splitdatestring[1] + " " + splitdatestring[2] + " " +
    splitdatestring[5] + " " + splitdatestring[3])

 // toString gives this format: Tue Feb 6 19:00:00 UTC+1100 2001
 // this function returns (from 0 to 5) 'word' 1, 2, 5, 3
 // in this case Feb 6 2001 19:00:00
 // DateValue understands this format

Quote:
}

:~P

Justin


Quote:

> Hello folks

> If you like me send dates from client to server as strings, to go into a
> database, you'll know that DateValue needs a certain format. Here's a
> function (first draft?) to help-

> function date_to_DateValue(datetime) {

>  var splitdatestring

>  splitdatestring = split(datetime.toString(), " ")

>  return splitdatestring(1) + " " + splitdatestring(2) + " " +
>     splitdatestring(5) + " " + splitdatestring(3)

>  // toString gives this format: Tue Feb 6 19:00:00 UTC+1100 2001
>  // Note 19:00 so am/pm is preserved
>  // this function returns (from 0 to 5) 'word' 1, 2, 5, 3
>  // in this case Feb 6 2001 19:00:00
>  // DateValue understands this format

> }

> cheers
> J



Fri, 25 Jul 2003 18:35:10 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. 4 digit date w date function

2. Some may find this handy

3. Handy one lines but...

4. Date - date = date

5. Compare date in form with date/time in form with date/time in database

6. how to handle NULL values from a FORM when using date string functions - help please

7. Working with Date functions

8. Writing a Date & Time function

9. pass a variable into date function

10. Retrieving client side date settings using toLocalestring function

11. Date function

12. Javascript 1.0 Date Validation Function

 

 
Powered by phpBB® Forum Software