| | |
please hlep me in js
Please support our HTML and CSS advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2007
Posts: 83
Reputation:
Solved Threads: 2
You say in the title js... if you mean Javascript, then you should post in the Javascritp lists, you'll get better results... If it is a typo and you meant JSP, then I will see what I can do...
However, the priciple is basically the same...
You can build a new date object from the ISO standard string format then use that date object with a date format object to output the date anyway you like...
Do a quick search for SimpleDateFormat on google and you will find pretty much everything you need...
Sorry, but there is too much to detail here...
If it is Javascript you are looking at, you can certainly do it similarly...
If the date is coming from a database, see what you can do for the formating prior to extracting the date, this is DB dependant so I can't give you specifics there, but for example, I use PostgreSQL 8.2 in many of my applications and I usually store timestamp with timezone... Then I can select it as a date which outputs as 4/1/2007 or similar...
If the dates are instrings you can always build a parser routine in js or java to do the work if you like...
String sMyDate = "Sun Apr 1 00:00:00 UTC+200 2007";
String[] aDateParts = sMyDate.split(" ");//the empty space
HashMap<String, Integer> hm = new HashMap(12);
hm.put("Apr", 4); // just a simple mapping
String sDisplayDate = hm.get(aDateParts[1]) + "/" + aDateParts[2] + "/" + aDateParts[5] + " " + aDateParts[3];
That is about it if you are doing string manipulation, which in some cases is faster than creating a date from a string, reformating it using date formatter then outputting it as a date again...
If you have any questions feel free to contact me... The string manipulation method will work in Javascript too, with almost the same code...
However, the priciple is basically the same...
You can build a new date object from the ISO standard string format then use that date object with a date format object to output the date anyway you like...
Do a quick search for SimpleDateFormat on google and you will find pretty much everything you need...
Sorry, but there is too much to detail here...
If it is Javascript you are looking at, you can certainly do it similarly...
If the date is coming from a database, see what you can do for the formating prior to extracting the date, this is DB dependant so I can't give you specifics there, but for example, I use PostgreSQL 8.2 in many of my applications and I usually store timestamp with timezone... Then I can select it as a date which outputs as 4/1/2007 or similar...
If the dates are instrings you can always build a parser routine in js or java to do the work if you like...
String sMyDate = "Sun Apr 1 00:00:00 UTC+200 2007";
String[] aDateParts = sMyDate.split(" ");//the empty space
HashMap<String, Integer> hm = new HashMap(12);
hm.put("Apr", 4); // just a simple mapping
String sDisplayDate = hm.get(aDateParts[1]) + "/" + aDateParts[2] + "/" + aDateParts[5] + " " + aDateParts[3];
That is about it if you are doing string manipulation, which in some cases is faster than creating a date from a string, reformating it using date formatter then outputting it as a date again...
If you have any questions feel free to contact me... The string manipulation method will work in Javascript too, with almost the same code...
Last edited by rgtaylor; Apr 6th, 2007 at 3:54 am. Reason: typo
![]() |
Similar Threads
- need hlep with finding a topic for my final year project (Computer Science)
- Forum lurkers, introduce yourself ... !! (Community Introductions)
- Need Help on showInputDialog (Java)
- finding area of something (Computer Science)
- something wrong with IE6 (Web Browsers)
Other Threads in the HTML and CSS Forum
- Previous Thread: newbie??? Including text files in html
- Next Thread: getting layermovement in netscape
| Thread Tools | Search this Thread |
appointments asp background backgroundcolor beta browser bug calendar cart cgi code codeinjection corporateidentity css design development displayimageinsteadofflash dreamweaver emailmarketing epilepsy explorer firefox flash form format google griefers hackers hitcounter hover html ide ie7 ie8 iframe image images internet internetexplorer intranet iphone javascript jpeg layout macbook maps marketshare microsoft mozilla multimedia navigationbars news offshoreoutsourcingcompany opacity opera optimization pnginie6 positioning problem scroll seo shopping studio swf swf. textcolor timecolor titletags url urlseparatedwords visual visualization web webdevelopment webform website windows7





