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')
Related
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.
I'm making an app with laravel, this features a calendar. I'm using "fullcalendar" which is very restricting on date format and AFAIK only accepts 'yyyy/mm/dd'. I'm using the jQuery datepicker and have edited the formatting to make it work. That all works fine and on the insert for a long time I would never get this error, however suddenly it's started giving me this error after days of not having it. I really don't understand. Unless there's a way to change fullcalendar formatting to match the accepted formatting for SQL, which has not affected my app since now, then I'd love to hear it.
(error: QLSTATE[22007]: Invalid datetime format: 1292 Incorrect date value: '05/14/2020' for column)
Thanks.
fixed it, my formatter was broken
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've seen a couple of posts doing the reverse for mysql, but I'm looking for a way to change a unix timestamp to a human readable date (ideally one I can change the format of) and I haven't been able to find anything so far.
I'm storing a date pulled from an XML feed, via NokoGiri (in Rails 3.1.1) as part of a hash:
'date' => i.xpath('#unix-timestamp')
which gets the number fine, but how the devil do you make this DD-MM-YYYY to be put in one of my views?
I've tried Time.at( (i.xpath('#unix-timestamp') ) to no avail; I just get the error 'can't convert Nokogiri::XML::NodeSet into an exact number' and now I've hit a wall
Much gratitude for any help!
Time.at is definitely a call that should work to convert from epoch time to a ruby Time object (see here for an example). So it seems like you need to work on converting your XML result into something more usable. I think you want to try using NodeSet#text to get a string output, then converting that to an integer:
Time.at(i.xpath('#unix-timestamp').text.to_i)
There's a decent but basic tutorial for NokoGiri in the Engineyard blog
You can use like : DateTime.strptime("1373210218",'%s')
and also Time.at(1373210218).strftime("%B %e, %Y at %I:%M %p")
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.