# Playing with dates

**URL:** <https://forum.kirupa.com/t/playing-with-dates/260207>\
**Category:** Uncategorized\
**Created:** [May 13, 2008, 2:51pm UTC](https://forum.kirupa.com/t/playing-with-dates/260207 "2008-05-13T14:51:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Multi\_Task](https://avatars.discourse-cdn.com/v4/letter/m/c6cbf5/32.png) [@Multi\_Task](https://forum.kirupa.com/u/Multi_Task)\
**Post date:** [May 13, 2008, 2:51pm UTC](https://forum.kirupa.com/t/playing-with-dates/260207/1 "2008-05-13T14:51:52Z")

</div>

how can I get this format in as3?

YYYY-MM-DD , HH:MM:SS

Here is what I have put together however it doesnt give me right day.

```auto

public function getDate(e:Event):void {
    
var date:Date = new Date();
var yr = date.getFullYear();
var mnth = date.getMonth()+1;
var day = date.getDay();
var hr:int = date.getHours(); 
var mn:int = date.getMinutes();
var time:String = hr+":"+mn;
trace(yr+"-"+mnth+"-"+day+" "+time); 

```

Instead it gives me a single for day of week it is, How can I get the actual day number so today is the 12th 2008-5-12 for example?

---

<div class="post-metadata">

**Author:** ![krilnon](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/krilnon/32/34_2.png) [@krilnon](https://forum.kirupa.com/u/krilnon)\
**Post date:** [May 13, 2008, 5:05pm UTC](https://forum.kirupa.com/t/playing-with-dates/260207/2 "2008-05-13T17:05:53Z")

</div>

```auto
var date:Date = new Date();
var yr = date.getFullYear();
var mnth = date.getMonth()+1;
var day = date.getDate();
var hr:int = date.getHours(); 
var mn:int = date.getMinutes();
var time:String = hr+":"+mn;
trace(yr+"-"+mnth+"-"+day+", "+date.toTimeString().slice(0, 8));

```
