I want to display date year like 2K19
In Php or wordpress
Example 08 OKT 2019 to 08 OKT 2K19
strftime("%d %b 2K%y");
Obviously this won't work for dates prior to 1 January 2000.
Related
Whenever I extract raw data from this specific tool I am getting the date format of
Fri Sep 2 10:29:50 2022
Fri Sep 9 10:31:01 2022
Mon Sep 12 10:32:28 2022
and I am having a hard time converting it to this kind of format in Google Sheet
9/2/2022 10:29
9/9/2022 10:31
9/12/2022 10:32
Already tried using different of formating but still can't convert it to the above format.
use:
=ARRAYFORMULA(IF(A1:A5="",,REGEXREPLACE(TRIM(A1:A5),
"(.*) (.*) (.*) (.*) (.*)", "$2/$3/$5 $4")*1))
then do:
Date value
=ArrayFormula(IF(A2:A="",,
DATEVALUE(REGEXEXTRACT(TRIM(A2:A), "(.+\d{1,2}) \d{1,2}:")&" "®EXEXTRACT(A2:A, " (....\z)"))+
TIMEVALUE(REGEXEXTRACT(TRIM(A2:A), " (\d{1,2}:\d{1,2}:\d{1,2}) "))))
Custom date and time formats
Custom number formats
I have a date in my mongodb database in following format
{
"_id" : ObjectId("5b8cd5e5cf36cb517c91910e"),
"date" : ISODate("2018-09-04T23:58:00.000Z")
}
When I show it by using moment on front end it gets increased by one day so 2018-09-04 becomes 2018-09-05
On front end I do this
moment(date).format('dddd MMM DD, YYYY')
I want same date extracted from the database that is 2018-09-04
Any help is appreciated.
Edit ->
When I console it on back end I see this
date: 2018-09-04T23:58:00.000Z
And on front end
date: "Thu Sep 06 2018 05:28:00 GMT+0530 (India Standard Time)"
Mongodb stores dates in ISO formats, it depends on where (in what timezones) your server and client are located. You can use the below.
The format for date you are getting is UTC format, when it will get converted to IST, it would show the difference. It means the following :-
If I get 2019-09-26T18:30:00.000Z as date in UTC. It is equivalent to Fri Sep 27 2019 00:00:00 GMT+0530 (India Standard Time). Please look at the difference 5hrs 30 mins. Incrementing/decrementing any thing on this and showing in IST would be wrong again as per the timezone is concerned.
If you do
new Date(date).toUTCString()
It will show you "Thu, 26 Sep 2019 18:30:00 GMT" In GMT which is exact.
It seems like a timezone issue.
If I run
console.log(moment('2018-09-04T23:58:00.000Z').utcOffset("+00:00").format());
console.log(moment('2018-09-04T23:58:00.000Z').utcOffset("+05:30").format());
console.log(moment('2018-09-04T23:58:00.000Z').utcOffset("+00:00").format('dddd MMM DD, YYYY'));
console.log(moment('2018-09-04T23:58:00.000Z').utcOffset("+05:30").format('dddd MMM DD, YYYY'));
I get
2018-09-04T23:58:00Z
2018-09-05T05:28:00+05:30
Tuesday Sep 04, 2018
Wednesday Sep 05, 2018
Which is off by one day
I have an array:
my #array = ( "\"Passing\" on Wed 12 Jan 2015 09:19:14 AM PST",
"\"Passing\" on Wed 12 Jan 2015 09:19:25 AM PST",
"\"Test Activation\" on Tues 14 Jan 2015 12:05:14 PM PST",
"\"Run Phase\" on Tues 14 Jan 2015 12:06:14 PM PST",
"\"Test Activation\" on Tues 13 Jan 2015 11:43:12 PM PST")
I want to remove the duplicate string line BUT keep the one that is most recent. So I want it to look like:
my #array = ("\"Passing\" on Wed 12 Jan 2015 09:19:25 AM PST",
"\"Test Activation\" on Tues 14 Jan 2015 12:05:14 PM PST",
"\"Run Phase\" on Tues 14 Jan 2015 12:06:14 PM PST")
I can't think of an easy way to do this... I was thinking about using some regex to compare the strings ( /\".*\"/ ) and have it remove duplicates it finds, but I'm not sure how to deal with the date/time.
Any suggestions are most welcome!
There's several options to parse and compare the dates. Simplest is to use the built in Time::Piece. Use strptime for parsing and compare with $time->epoch.
Unfortunately for you, abbreviated time zone names are ambiguous. PST can mean US Pacific Standard Time or Philippine Standard Time. This may cause strptime's %Z format to choke, YMMV. From my strptime man page...
The %Z format specifier only accepts time zone abbreviations of the local time zone, or the value "GMT". This limitation is because of ambiguity due to of the over loading of time zone abbreviations. One such example is EST which is both Eastern Standard Time and Eastern Australia Summer Time.
You may need to pre-process the date formats and convert them to time zone offsets. You can use Time::Zone for this and its distinctly North American slant.
use Time::Zone;
use Time::Piece;
my $offset = sprintf "%+d", (tz_offset("PST") / 60 / 60);
my $time = Time::Piece->strptime(
"Wed 12 Jan 2015 09:19:14 AM $offset",
"%a %d %b %Y %I:%M:%S %p %z"
);
print $time->datetime, "\n";
print $time->epoch, "\n";
But try %Z first and see if it works.
Extracting the dates is also left as an exercise.
I'm working on a podcast (on-the-road events) that contains future dates and different time zones.
<pubDate>Wed, 14 Nov 2012 19:00:00 EST</pubDate>
<pubDate>Wed, 25 Jul 2012 19:00:00 CDT</pubDate>
<pubDate>Thu, 29 Mar 2012 19:00:00 MDT</pubDate>
When I parse it with PHP4 (note PHP4), using date() and strtotime(), it adjusts the information and outputs it in the current timezone of the server (including daylight saving time changes).
Code...
date("g:ia T", strtotime($item->pubDate));
Example...
<pubDate>Thu, 29 Mar 2012 19:00:00 MDT</pubDate> outputs 8:00pm CDT
The expected output is 7:00pm MDT
Again, I'm using PHP4, so I can't do DateTime()-type stuff.
Basically, I just want it to just return the characters, instead of interpreting the characters. Maybe I shouldn't use date() or strtotime() at all, but I'm not sure of another way to turn Wed into Wednesday, 19:00:00 into 7:00pm, etc.
im trying to convert a time stamp in seconds from Jan 01 1901 to the current date.
for example,
time stamp 3465468225 translate to a date in 2010. does anyone know of a way to do this in unix/linux? thanks.
In R, it is as simple as this:
> as.POSIXct(3465468225, origin="1901-01-01")
[1] "2010-10-25 15:03:45 CDT"
>
This uses appropriate wrappers around C-level calls gmtime() / localtime() plus time formatting via strftime().
On GNU and POSIX systems you can obtain the date string using seconds since Epoch (1970-01-01 00:00:00 UTC) as:
$ date --date=#1289495920
Thu Nov 11 12:18:40 EST 2010
You should handle the offset since Jan 01 1901 yourself.