Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 12-14-2003, 10:46 PM   #1
Brusca
Registered User
 
Join Date: Nov 2002
Location: Brisvegas
Posts: 14
Send a message via ICQ to Brusca
Default Date Format

Hi Guys,
I have a date field which is coming into Flash from a .net webservice. It is being called on from a webservice class (not a component...and not my choice). But the date field comes into flash formatted like this.

Wed Dec 24 00:00:00 GMT+1000 2003

I was curious to know if there was a simple way to format this date in flash to display the date like this.

24/12/2003

Cheers if anyone can help

Brusca
Brusca is offline   Reply With Quote
Old 12-14-2003, 11:59 PM   #2
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Howdy and Welcome...

No... There isn't really easy way to change that format...
It might not be the closest one, but I have seen a couple of date format related prototypes at Layer51...
http://proto.layer51.com

Go check it out and modify the script and I think it will be easier to do it that way...

Please do not crosspost... We hate people doing that... Besides, this question does not really have much to do with that server side forum except that you are calling a web service...

Last edited by CyanBlue; 12-15-2003 at 12:02 AM.
CyanBlue is offline   Reply With Quote
Old 12-15-2003, 03:00 AM   #3
farafiro
Addicted To FLASH
 
farafiro's Avatar
 
Join Date: Dec 2001
Location: Egyptian in UAE
Posts: 12,436
Send a message via MSN to farafiro Send a message via Yahoo to farafiro
Default

ActionScript Code:
var d:Date = new Date(); trace(d.getDate()+"/"+d.getMonth()+"/"+d.getFullYear());
farafiro is offline   Reply With Quote
Old 12-15-2003, 03:06 AM   #4
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

farafiro... That will work for most of the cases, but he wanted to get the date from this string that he gets from the webservice call...

Wed Dec 24 00:00:00 GMT+1000 2003

__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 12-15-2003, 03:08 AM   #5
farafiro
Addicted To FLASH
 
farafiro's Avatar
 
Join Date: Dec 2001
Location: Egyptian in UAE
Posts: 12,436
Send a message via MSN to farafiro Send a message via Yahoo to farafiro
Default

I don't get what you/he mean by that
but if you know the format you can do it by a simple array and a subString or a subStr to split it and reorganise it
farafiro is offline   Reply With Quote
Old 12-15-2003, 04:31 AM   #6
Brusca
Registered User
 
Join Date: Nov 2002
Location: Brisvegas
Posts: 14
Send a message via ICQ to Brusca
Default

its ok I worked it out.

I was trying the substr method at first but it was not reliable as some days are 2 digits and others 1 digit.

all I did was convert the date that was coming from my webservice to a new date.

EventDate = new Date();
EventDate = Wed Dec 24 00:00:00 GMT+1000 2003 //value coming in from web service


myDay = EventDate.getDate();
myMonth = EventDate.getMonth()+1; // allow for the month array
myYear = EventDate.getYear();

newDateFormat = myDay + "/" + myMonth + "/" + myYear;

Hope that helps someone who may have thje same issues.

Cheers Brusca
Brusca is offline   Reply With Quote
Old 12-15-2003, 09:04 AM   #7
divarch
Not a teenager
 
divarch's Avatar
 
Join Date: Nov 2003
Location: Belgrade, Serbia
Posts: 618
Send a message via MSN to divarch Send a message via Yahoo to divarch
Default

Hello, the easiest way would be like this:
ActionScript Code:
myDate=new Date(); day=myDate.getDate(); month=myDate.getMonth()+1; year="0"+(myDate.getYear()-100) newDate=[]; newDate.push(day+"/"+month+"/"+year) trace(newDate[0]) //outputs 15/12/03

You don't need arrays for that, I am just kinda used to them.
You can join it all in a single string also.
You can format the year as 03, or you can leave it in YYYY format,
Hope this helps.
divarch is offline   Reply With Quote
Old 08-03-2005, 04:51 PM   #8
nicetim
Registered User
 
Join Date: Jan 2005
Posts: 6
Default

i need to do the same thing, except in my case, i am using components
A webserviceConnect, a DataSet and a DataGrid.
The date ends up in the grid with that extremly long formatting. I tried to change the components to format that field but it dosnt work.

Please help

Thanks
tim
nicetim is offline   Reply With Quote
Old 10-04-2005, 09:36 AM   #9
alexurquhart
Registered User
 
Join Date: Sep 2005
Posts: 9
Default

Does ANYBODY know how to do this, I have seen nothing but unanswered questions on this. How do you format the date before it populates a datagrid.
alexurquhart is offline   Reply With Quote
Old 10-22-2009, 08:19 PM   #10
sudheery
Registered User
 
Join Date: Oct 2009
Posts: 1
Default try this

You can achieve date formatting like this:
Code:
Step 1:  In your mxml file (where you have the data grid) declare a date formatter like this:

<mx:DateFormatter id="df" formatString="MM/DD/YYYY" />

Step 2:
   In your Script block in the same .mxml file i.e., inside "<mx:Script>	<![CDATA[ ........] </mx:Script", define the following function:

 private function displayFormattedDate(d:Object,c:DataGridColumn):String {
	var retval : String = "";
	try {
	    retval = df.format(d[c.dataField]);
	}catch (errObject:Error) { }
        return retval;
 }

Step 3:
  Add this function to your column in data grid
  ex: 
  <mx:DataGrid ....>
    ......
    ......
     <mx:DataGridColumn dataField="itemDate"  labelFunction="displayFormattedDate"/>
    .....
    .....
  </mx:DataGrid>
Hope that helps.

Sudheer

Quote:
Originally Posted by nicetim View Post
i need to do the same thing, except in my case, i am using components
A webserviceConnect, a DataSet and a DataGrid.
The date ends up in the grid with that extremly long formatting. I tried to change the components to format that field but it dosnt work.

Please help

Thanks
tim
sudheery is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:10 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.