# Today's date format

**URL:** https://discuss.kotlinlang.org/t/todays-date-format/4855
**Category:** JavaScript
**Created:** [October 4, 2017, 8:53am UTC](https://discuss.kotlinlang.org/t/todays-date-format/4855 "2017-10-04T08:53:42Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![cortell](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@cortell](https://discuss.kotlinlang.org/u/cortell)
#### Post date: [October 4, 2017, 8:53am UTC](https://discuss.kotlinlang.org/t/todays-date-format/4855/1 "2017-10-04T08:53:42Z")

</div>

Hi,  
I’m really new to Kotlin and i’m struggelling  
to display today’s date formatted like dd/mm/YYY in a JS project.

Is there a way to go through this without using the magic “js” method ?

---

<div class="post-metadata">

### Author: ![bashor](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/bashor/32/1431_2.png) [@bashor](https://discuss.kotlinlang.org/u/bashor)
#### Post date: [October 9, 2017, 8:41pm UTC](https://discuss.kotlinlang.org/t/todays-date-format/4855/2 "2017-10-09T20:41:09Z")

</div>

> Is there a way to go through this without using the magic “js” method ?

It’s possible, but until [KT-2506](https://youtrack.jetbrains.com/issue/KT-2506) or [KT-20694](https://youtrack.jetbrains.com/issue/KT-20694) are not fixed it requires to write some declarations, like:

([open on try.kotl.in](https://try.kotl.in/#/UserProjects/cc2o9767q7p0mg6iabgld4kd3p/3kjmvbtod5vrhlnv5ce1nmkqm8))

```kotlin
external interface JsDateLocaleOptions {
    // The representation of the year. Possible values are "numeric", "2-digit".
    val year: String
    // The representation of the month. Possible values are "numeric", "2-digit", "narrow", "short", "long".
	val month: String
	// The representation of the day. Possible values are "numeric", "2-digit".
	val day: String
}

@JsName("Date")
external class JsDate {
    constructor(s: String)
    
    fun toLocaleDateString(locale: String, options: JsDateLocaleOptions? = definedExternally): String
}

fun main(args: Array<String>) {
    val myoptions = object : JsDateLocaleOptions {
        override val year = "2-digit"
        override val month = "2-digit"
        override val day = "2-digit"
    }
    
    println(JsDate("12/22/2018").toLocaleDateString("en-us", myoptions))
}

```
