logo
down
shadow

R incorrect value of date function


R incorrect value of date function

By : user2956685
Date : November 22 2020, 10:56 AM
may help you . I didn't see this simple solution in the linked questions, so I'm adding it here too.
In base R you can simply use as.POSIXlt class which provides year attribute. You can then simply reduce 100 years.
code :
(Date <- c("65-05-14", "15-05-14", "25-05-14", "34-05-14"))
## [1] "65-05-14" "15-05-14" "25-05-14" "34-05-14"
Date <- as.POSIXlt(Date, format = "%y-%m-%d")
Date$year <- Date$year - 100L
Date # Alternatively, you could also do `as.Date(Date)`
## [1] "1965-05-14 IDT" "1915-05-14 IDT" "1925-05-14 IDT" "1934-05-14 IDT"


Share : facebook icon twitter icon
Php date function result is incorrect

Php date function result is incorrect


By : user3903391
Date : March 29 2020, 07:55 AM
This might help you You have a typo. The 2nd argument to explode() should be $dated, rather than $date. If you do this, the time is correctly displayed.
code :
<?php
function perfect_date_format($date) {
    $dated = str_replace(array(" ", ":"), "-", $date);
    list($year, $month, $day, $hour, $minute) = explode("-", $dated);
    $niceday = @date("H:ia \o\\n\ l, F jS, Y", mktime($hour, $minute, 0, $month, $day, $year));
    return $niceday;
}

echo perfect_date_format('2011-12-17 03:45:00') . "\n";
?>
03:45am on Saturday, December 17th, 2011
PHP date() function returning incorrect values

PHP date() function returning incorrect values


By : sug
Date : March 29 2020, 07:55 AM
Hope that helps Looks like that timestamp is in milliseconds, not seconds as PHP uses them.
Do date(..., $date / 1000).
strtotime() function returning incorrect date

strtotime() function returning incorrect date


By : Little Bit
Date : March 29 2020, 07:55 AM
Does that help I am getting the date of the next week even when I have set the timezone to UTC-9. , You can append timezone UTC-9 to the string:
code :
$last_time_instance=strtotime('Wednesday 16:00:00 UTC-9');  // 1490803200

$time_instance_formatted=date('d-m-Y H:i:s',$last_time_instance);  // 29-03-2017 12:00:00
Date function returning incorrect result

Date function returning incorrect result


By : Alexander Baker
Date : March 29 2020, 07:55 AM
Hope this helps You can always use nsdateformatter.com to check if your dateFormat for your formatter is correct (next to the Examples check Reference which shows you what each letter/letters represent).
In your case, you have to be carefull on dateFormat's case sensitive. Days and years are represented by small letters
code :
dateFormatter.dateFormat = "yyyyMMdd"
PHP date function producing incorrect result

PHP date function producing incorrect result


By : Victor
Date : March 29 2020, 07:55 AM
I hope this helps you . I think you might want to read the documentation for the date() function again. There is no b option that I'm aware of and:
code :
echo date('M j, Y', strtotime('2013-02-01'));
Related Posts Related Posts :
  • Re coding in R using complicated statement
  • accumulating functions and closures in R
  • How do you combine two columns into a new column in a dataframe made of two or more different csv files?
  • Twitter authentication fails
  • Summing Values of One Vector Conditional on Values of Another Vector
  • draw cube into 3D scatterplot in RGL
  • lme4 translate formula to code in 3-level model
  • How to draw single axis plot in R
  • Combine geom_tile() and facet_grid/facet_wrap and remove space between tiles (ggplot2)
  • Use snpStats with R version 3.0.1
  • Makefile gives strange error while compiling markdown file into .docx file
  • How to determine whether a points lies in an ellipse
  • Summarize data already grouped in r
  • Is the bigvis package for R not available for R version 3.0.1?
  • Operator overloading in R reference classes
  • How to enable user to switch between ggplot2 and gVis graphs in R Shiny?
  • Is there an easy way to separate categorical vs continuous variables into two dataset in R
  • Correct previous year by id within R
  • Installation of rdyncall package for R
  • ggplot2 plot that evaluates the percentage and mean of a third variable at intersecting points
  • Error Handling with Lapply
  • data.table - split multiple columns
  • How to compute the overall mean for several files in R?
  • R: Graph Plotting: Subscripts in the legend like LaTeX
  • Restructuring data in R
  • Distance of pointsfrom cluster centers after K means clustering
  • Package "Imports" not loading in R development package
  • r - run a user defined function several times by taking column elements as parameters
  • Create input$selection to subset data AND radiobuttons to choose plot type in Shiny
  • Generate crosstabulations from dataframe of categorical variables in survey
  • Restructure output of R summary function
  • New behavior in data.table? .N / something with `by` (calculate proportion)
  • search certain number vector in R
  • R version doesn't support quartz graphic device - RStudio won't plot
  • Referencing a function parameter in R
  • How to synchronize signals using a cross-correlation and FFT in R?
  • Plotting coefficients and corresponding confidence intervals
  • passing expressions to curve() within a function
  • More effective merging of matched column with duplicates in data.table
  • Easy way to export multiple data.frame to multiple Excel worksheets
  • R Foreach Iterator - Walkforward
  • Table format and output in R
  • Restructuring data and duplicating rows in R
  • use ggplot2 to plot two lines with ribbons
  • how to plot a graph on lattice with two different colors
  • How can I keep a date formatted in R using sqldf?
  • Generating simulation data based on a specified distribution
  • Joining list of data frames in R
  • Subset data in R
  • R: How to avoid 2 'for' loops in R in this function
  • + signs appearing in console in R
  • how to create a dataframe form a lists within a list in R
  • Best way to combine and keep columns
  • Using identify and attach in a function
  • Apply function to each submatrix
  • How to assign regular strings for quarterly and monthly observation labels to the row names of a data frame?
  • Adjust hexbin legend breaks
  • Different lowess curves in plot and qplot in R
  • Extract words only with R
  • switch case: several equivalent cases expressions in r
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org