I am using DateTimePicker in my react-native app.But when i try to get date in my text field it returns me something like that Monday June 21 2021 17:34:53 GMT.... but I want to get only date which is 2021:06:21 currently i am getting date like that new Date() and in my text I done like that <Text>{date.toString("yyyy-MM-dd")}</Text>
you can do
yourDate.toISOString().slice(0,10).replace(/-/g,"")
in jsx code
<Text>{yourDate.toISOString().slice(0,10).replace(/-/g,"")}</Text>
base this answer
OR
use moment library
<Text>{ moment(date).format('MM-DD-YYYY')}</Text>
Use moment
install moment
npm install moment --save
replace your text tag with this
<Text>{moment(date).format("MMM Do YY")}</Text>
ref : https://momentjs.com/
OR
you can also use toLocaleDateString() to get only date
<Text>{date.toLocaleDateString()}</Text>
OR
You can also convert first your date into string
<Text>{date.toString().substr(4 ,12)}</Text>
I would recommend using https://momentjs.com/.
then you can write moment(yourDate).format('MM/DD/YYYY'); or whatever format you want.
Related
I got the problem like this
2022-12-06T17:00:00.000Z
This is my code:
<Calendar
inputId="range"
v-model="collectionItems.StartOn"
selectionMode="range"
:manualInput="false"
dateFormat="yy-mm-dd"
>
</Calendar>
But I want like this
2022-12-05
To change the date format in Vuejs v3, you can use the date-fns.
npm install date-fns
and you can format date like bellow
var formatedDate = format(date, 'yyyy-MM-dd');
If you want to working code, I made it available on my codepen: https://codepen.io/maymeow/pen/xxzmgKJ
Hope it helps.
You have to format your collectionItems.StartOn before applying it to your custom component Calendar
Doest it come from your backend?
Either you parse it on your backend before sending it to your frontend, or you parse it via a JS date library like date-fns, dayjs or moment;
Install via yarn or npm and just follow the documentation ;)
I'm having a problem with momentjs. I'm trying to generate all days from a specific month by using the startOf and endOf methods on my moment object like this:
moment('2017-07-17').startOf('month')
However, when I log the return value in the console it returns "2017-06-30T22:00:00.000Z".
I expect it to just be "2017-07-01T00:00:00.000Z".
I am using vue 2.x if that makes any difference, and I'm importing moment like import moment from 'moment';.
Its because of timezone moment('2017-07-17') will take your local timezone which looks to be CEST.
instead do
moment.utc('2017-07-17')
How can i check the system date format? Tried with the code below, but when i change my system's date format to another date format to test the code, it's still showing the date format before changed!
System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern()
Ok. I managed to find the solution, the 'CurrentCulture' has to be 'CurrentUICulture', instead of CurrentCulture. Which is as below:
System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat.ShortDatePattern()
I am trying to format dates in an HTML cfgrid. I cannot seem to make it work in CF when using HTML as the grid type. I have also tried doing it in MSSQL by using - CONVERT(VARCHAR(10), startDate, 101) AS startDate.
When I do that it shows up right in the grid but the grid will not sort on the date properly.
I understand why converting it to varchar screws up the sort but I cannot seem to make this work in either CF or SQL.
Anyone know of a way to make it show up in the grid in a mm/dd/yyyy format and also sort on the date properly?
Ability to use the mask attribute in html grids was added in CF9. To get it to work on dates you also have to specify type=date
<cfgridcolumn mask="m/d/Y" type="date" ... >
If you are using an html cfgrid, you need to use the formats found in the Ext JS Date class. NOT the date format for Flash.
Here is a link to the Ext JS Date class
<cfgridcolumn ... mask="mm/dd/yy">
source
I am using drupal databas ein one of my application. Drupal profile saves date in following format:
a:3:{s:5:"month";s:1:"2";s:3:"day";s:2:"18";s:4:"year";s:4:"1995";}
I can read this with data reader but how to convert in a proper display like DD/MM/YYYY or YYYY/MM/DD
Well, you can kind of see the values for month, day and year in that zany string. Presumably there is something in VB that can help you parse and glue together the string as you need it?
You might look into how PHP's unserialize() works, that will reformat the string to a more usable array.
Most of all, dont use profile, use content_profile and cck. Problem solved. Unserializing PHP serialization can get a bit hairy.