Parse Unix timestamp with offset in php example timestamp 1671847200000-0600 - laravel

I am trying to parse the Unix timestamp in Laravel
/Date(1671847200000-0600)/
where 1671847200000 is the timestamp and this is -0600 offset (-06:00 i.e. -HH::mm)
expected output be like
2022-12-23 18:00:00

Related

Jmeter - saving the result using file name

I need to append the summary result into CSV file, I tried but getting below error
2022-08-04 12:21:25,553 WARN o.a.j.s.CSVSaveService: Unknown column name
2022-08-04 12:21:25,553 INFO o.a.j.s.CSVSaveService: C:\Users\Premkumar\Desktop\onescv.csv does not appear to have a valid header. Using default configuration.
2022-08-04 12:21:25,553 WARN o.a.j.s.CSVSaveService: Cannot parse timestamp: '', will try following formats [yyyy/MM/dd HH:mm:ss.SSS, yyyy/MM/dd HH:mm:ss, yyyy-MM-dd HH:mm:ss.SSS, yyyy-MM-dd HH:mm:ss, MM/dd/yy HH:mm:ss]
2022-08-04 12:21:25,553 INFO o.a.j.s.CSVSaveService: did not match yyyy/MM/dd HH:mm:ss.SSS, trying next date format
2022-08-04 12:21:25,553 INFO o.a.j.s.CSVSaveService: did not match yyyy/MM/dd HH:mm:ss, trying next date format
2022-08-04 12:21:25,553 INFO o.a.j.s.CSVSaveService: did not match yyyy-MM-dd HH:mm:ss.SSS, trying next date format
2022-08-04 12:21:25,553 INFO o.a.j.s.CSVSaveService: did not match yyyy-MM-dd HH:mm:ss, trying next date format
2022-08-04 12:21:25,553 INFO o.a.j.s.CSVSaveService: did not match MM/dd/yy HH:mm:ss, trying next date format
2022-08-04 12:21:25,553 WARN o.a.j.s.CSVSaveService: Error parsing field 'timeStamp' at line 1. java.text.ParseException: No date-time format found matching
I have tried by changing the date formats in Jmeter properties also as below;
# Timestamp format - this only affects CSV output files
# legitimate values: none, ms, or a format suitable for SimpleDateFormat
#jmeter.save.saveservice.timestamp_format=ms
#jmeter.save.saveservice.timestamp_format=yyyy/MM/dd HH:mm:ss.SSS
If any suggestion plsenter code here
JMeter's .jtl files have the defined format like:
timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,failureMessage,bytes,sentBytes,grpThreads,allThreads,URL,Latency,IdleTime,Connect
1659509834675,57,Your-Sampler-Label,200,OK,Thread Group 1-6,text,true,,114,0,12,12,null,25,0,3
When you use Save Table Data button in the Summary Report listener the first 2 lines look like:
Label,# Samples,Average,Min,Max,Std. Dev.,Error %,Throughput,Received KB/sec,Sent KB/sec,Avg. Bytes
Your-Sampler-Label,42,282,53,490,132.23,0.000%,32.25806,3.59,0.00,114.0
JMeter is looking for a Unix timestamp like 1659509834675 and it gets Your-Sampler-Label instead which is causing the failure.
So there is no way to add the Summary Report data to the .jtl results file without breaking Listeners and HTML Reporting Dashboard generation, if you want to have Summary Report listener output as CSV you can use JMeter Plugins Command Line Tool as:
JMeterPluginsCMD.bat --generate-csv summary-report.csv --input-jtl /path/to/your/test/result.jtl --plugin-type SynthesisReport
This way you will have the Summary Report listener as a separate file.

How to convert unix timestamp to formatted date in ruby?

I'm struggling with ruby date api. I need to convert a timestamp number to formatted date. But when i use:
Time.at(1517486994710).to_datetime
or
DateTime.strptime("1517486994710",'%s')
(1517486994710 is unix timestamp for today), i see 50057 year as output. What i'm doing wrong?
You have the epoch with milliseconds. Use %Q formatter:
DateTime.strptime("1517486994710",'%Q')
#⇒ Thu, 01 Feb 2018 12:09:54 +0000
Your script is correct but your epoch is incorrect. Today epoch is 1517491785.
You probably got the js epoch which counts in milliseconds
DateTime.strptime("1517486994",'%s') # removed 710

Ruby unix date incorrect

I have the following Unix timestamp: 1478698378000
And I'm trying to show this as a datetime in Ruby, e.g.
<%= Time.at(#timestamp).to_datetime %>
Which should be returning a date of: Wed, 09 Nov 2016 13:32:58 GMT but the above code actually returns a date of: 48828-02-01T13:26:40+00:00 Ignore formatting!
As you can see it thinks that timestamp is 2nd Feb 48828 13:26:40.
Why is the datetime coming out completely incorrect and the year so far into the future like that? Checking the timestamp on http://www.epochconverter.com/ reveals the timestamp to be correct, so it's Ruby that's returning it incorrectly.
Time.at expects seconds as an argument and your timestamp is an amount of milliseconds. See documentation on Time.at
Why won’t you check the unix timestamp correctness against “Fashion Week Magazine” or “Cosmopolitan” Site?
Unix timestamp is an amount of seconds lasted since 1970-01-01 UTC:
date --date='#1478698378000'
mar feb 1 14:26:40 CET 48828
BTW, dropping last three zeroes gives you back what you’ve expected:
date --date='#1478698378'
mié nov 9 14:32:58 CET 2016

Converting timestamp with time zone to local time in Bash

I am trying to do basic time math in Bash having following timestamps from OpenDj:
createtimestamp: 20161123165725Z
I don't know what time zone the system will be set with, it can be with "Zulu" timezone (UTC) as above, or might be with some other timezone. The above timestamp is for the users on LDAP servers. What I need to do is to compare the timestamp of the user with a certain timestamp.
Question: how do I convert the timestamp with zone (Z) above to local timestamp or epoch time in Bash?
Maybe Dateutils will help
http://www.fresse.org/dateutils/
dateconv -i '%s' -f '%A, %d %b %Y' 1234567890
Friday, 13 Feb 2009
dateutils tools default to UTC (add -z your/timezone if needed).

Apache PIG - Convert millseconds into TimeStamp Unix

I've the following field: 1388481000000 as the number of milliseconds elapsed from the Unix Epoch (1970-01-01 UTC)
How can I convert to Unix TimeStamp?
I'm trying to use:
ToUnixTime(1388481000000,'dd/MM/yyyyHH:mm:ss','GMT')
but it gives me error...
How can I convert into Unix Timestamp? Many thanks!
You are mixing things up.ToUnixTime syntax is ToUnixTime(datetime) where the parameter is a datetime object.What you have is the milliseconds elapsed from the Unix epoch (1970-01-01 UTC).I assume you are trying to convert the milliseconds to a datetime object for which you will have to use ToDate and the syntax is ToDate(milliseconds).
ToDate(1388481000000)

Resources